I have two ObjectDataSources in my form.i want change data grid view datasource with ObjectDataSources.
Button's eventhandler to change ObjectDataSource1 is :
protected void lbnChangeInfo1_Click(object sender, EventArgs e)
{
gdvList.DataSource = null;
gdvList.DataBind();
gdvList.DataSource = odsWork1;
gdvList.DataBind();
}
Button's eventhandler to change ObjectDataSource2 is :
protected void lbnChangeInfo2_Click(object sender, EventArgs e)
{
gdvList.DataSource = null;
gdvList.DataBind();
gdvList.DataSource = odsWork2;
gdvList.DataBind();
}
When executed, this error is thrown:
Additional information: Both DataSource and DataSourceID are defined on 'gdvList'. Remove one definition.
change code with :
protected void lbnChangeInfo1_Click(object sender, EventArgs e)
{
gdvList.DataSource = null;
gdvList.DataSourceID = null;
gdvList.DataSource = odsWork1;
gdvList.DataBind();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.