开发者

ASP.NET C# - Do you need seperate datasources for each gridview of different tables in same database?

Sorry, this is a bit of a noob question, but do you need a separate datasources for each gridview if each gridview is accessing the same database but different tables in the database?

For example: I have 3 different grid views dispa开发者_JAVA百科ying searches for 1) given ZipCode and PlanCode, 2) given ZipCode, PlanCode, and Age, 3) given State Code and Carrier Code.

Here's the c# code-behind:

protected void Search_Zip_Plan_Age_Button_Click(object sender, EventArgs e)
{
    var _with1 = this.ZipPlan_SqlDataSource;
    _with1.SelectParameters.Clear();

    string ConnectionString = System.Configuration.ConfigurationManager.AppSettings["PriceFinderConnectionString"]
    _with1.SelectCommand = "ssp_get_zipcode_plan";
    _with1.SelectParameters.Add("ZipCode", this.ZipCode.Text);
    _with1.SelectParameters.Add("PlanCode", this.PlanCode.Text);
    _with1.SelectParameters.Add("Age", this.Age.Text);        

    _with1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;

    _with1.CancelSelectOnNullParameter = false;


    Search_Results_GridView.DataBind();
}

thanks!


You can reuse data source controls only if its the same query; otherwise, you need different data source controls.

HTH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜