Analysis of Common ASP. NET technologies (IV)

Source: Internet
Author: User
      • Data Source parameter settings during nested Data Binding

    Problem:

    My gridview control is nested in the datalist control. The datalist control has a binding column "quarter". The data source of the gridview control must be retrieved using the value of "quarter.
    How do I set parameters for the data source?

    Resolution:

    1. Set the data source control datatalbe, but it is not a parameter item for the time being. Later, you will dynamically add and modify parameters through method calls, this allows you to Dynamically Retrieve data based on changes in the value of quarter.

    2. Bind The gridview1 control to datatalbe and set the format style.
    Datasource = '<% # getdatasource (INT) (datarowview) container. dataitem) ["quarter"]) %>'

    3. Use the getdatasource method to reset the parameter for datasource of gridview1 based on the value of "quarter", as shown below:
    protected sqldatasource getdatasource (int32 parameters)
    {< br> sqldatasource SDS = datatable; // the data source control that is configured before but cannot meet the requirements
    If (SDS. selectparameters. count = 2) SDS. selectparameters. removeat (1);
    SDS. selectparameters. add ("quarter", convert. tostring (parameters);
    return SDS;
    }

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.