开发者

Both DataSource and DataSourceID are defined on 'getGridMerchantLocationData'. Remove one definition

开发者 https://www.devze.com 2023-01-10 20:44 出处:网络
I am a learner and i have a problem data binding the dataset. Please review my code and tell me where i am doing wrong. It does not bind and hence throws an exception \"Both DataSource and DataSourceI

I am a learner and i have a problem data binding the dataset. Please review my code and tell me where i am doing wrong. It does not bind and hence throws an exception "Both DataSource and DataSourceID are defined on 'getGridmerchantLocationData'. Remove one definition"

开发者_JAVA技巧

       <asp:ObjectDataSource ID="getGridMerchantLocationData" runat="server" 
       OldValuesParameterFormatString="original_{0}" 
       SelectMethod="GetLocations" TypeName="string">            
       </asp:ObjectDataSource>

Code Behind


protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.filllocation(ApplicationData.VAL_DEFAULT_SORT_LOCATION, ApplicationData.VAL_ASC); } }

public void BindData()
{ 


}
private void filllocation(string orderby, string order)
{
    DataSet ds = new BusinessLogic.BLL.Merchant2().getGridMerchantLocationData(CommonHelper.GetLoggedInMerchant(), orderby, order);
    if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
    {
        diableloc.DataSource = ds;
        diableloc.DataBind();
    }
    else
    {
        ds = null;
        diableloc.DataSource = ds;
        diableloc.DataBind();
    }

getGridMerchantLocationData has many columns but i just need one column out of it and bind it to the gridview. Please someone help me out! Thanks!!


Yes you cannot define the ObjectDataSource as being the datasource for your 'diableloc' control and in code assign the DataSource to 'ds' as well. You can only have one datasource for a control.

0

精彩评论

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