开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜