将数据绑定到网格视图不起作用

时间:2014-04-17 07:52:38

标签: c# asp.net

在下面的代码中,我在会话中得到2个变量,我试图通过传递客户端ID来绑定自定义控件中的值,在另一种情况下,我试图通过传递doumnet id将另一个值绑定到网格视图。但是自定义控件绑定成功但网格视图无法绑定它抛出error.pls帮助我解决问题

页面加载:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var SearchDoc = (SearchDoc)Session["Documentname"];
                var oDocumentID = SearchDoc.ClientID;
                var odoc = SearchDoc.DocumentID;
                DocumentServiceClient Doc = new DocumentServiceClient();
                DataSet dsField = Doc.GetClientFields(oDocumentID);
                DataSet dsField1 = Doc.GetDocumentsByDocumentID(odoc);//
                gmaFieldsContr.dtFieldsInfo = dsField.Tables[0];
                gmaFieldsContr.BindData();
                Attchdwnld.DataSource = dsField1.Tables[0];
                Attchdwnld.DataBind();}}

1 个答案:

答案 0 :(得分:0)

我解决了这个问题

 var SearchDoc = (SearchDoc)Session["Documentname"];
                var oDocumentID = SearchDoc.ClientID;
               string odoc = SearchDoc.DocumentID.ToString();
                DocumentServiceClient Doc = new DocumentServiceClient();
                DataSet dsField = Doc.GetClientFields(oDocumentID);
                DataTable dtDocument = Doc.GetDocumentsByDocumentID(odoc).Tables[0];
                gmaFieldsContr.dtFieldsInfo = dsField.Tables[0];
                gmaFieldsContr.BindData();
                Attchdwnld.DataSource = dtDocument; 
                Attchdwnld.DataBind();