将Objectdatasource绑定到网格 [英] Binding Objectdatasource to grid

查看:82
本文介绍了将Objectdatasource绑定到网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我正在尝试使用以下代码将数据集转换为arraylist

Hello Friends,
I was trying to convert dataset to arraylist, using following code

Public Shared Function getDailyDetails(ByVal Criteria As String, ByVal startRowIndex As Integer, ByVal maximumRows As Integer) As ArrayList
         Dim myArrayList As New ArrayList()
         Dim objConn As SqlConnection = getConnection()
         Dim strsql As String
         strsql = "select noticeid,comment,brandcategoryname,commentdate from tbl_QCNotice N inner join tbl_brandcategory B on B.brandcategoryid = N.brandcategoryid"
         Dim objDA As New SqlDataAdapter(strsql, objConn)
         Dim objDS As New DataSet
         Try
             objDA.Fill(objDS)
             Dim row As DataRow
             For Each row In objDS.Tables(0).Rows
                 myArrayList.Add(row)
             Next
         Catch ex As SqlException
         Finally
             objConn.Close()
             objConn.Dispose()
             objConn = Nothing
         End Try
         Return myArrayList
     End Function



后来我将这个数组列表绑定到objectdatasource



Later I''m binding this arraylist to objectdatasource

<asp:ObjectDataSource ID="odsJobs" runat="server"
                           EnablePaging="true" SelectMethod="getDailyDetails"
                           TypeName="AliaForms.AliaDAO.clsQualitycheck_DAO" SelectCountMethod="getDailyDetailsCount">
                           <SelectParameters>
                               <asp:ControlParameter ControlID="hdSearch" Name="Criteria" Type="String" DefaultValue="" PropertyName="Value"/>
                           </SelectParameters>



问题是当我将此数据源绑定到网格时



Problem is when I bind this datasource to grid

<acc:GridEuo SkinID="ProductView"  runat="server" DataSourceID="odsJobs" DataKeyNames="noticeid" AutoGenerateColumns="false">
       <columns>
           <asp:TemplateField HeaderText="NoticeID">
               <itemtemplate>
                   <asp:Label ID="lblnoticeid" runat="server" Text="<% #Eval(''noticeid'') %>">
               </itemtemplate>

           <asp:BoundField DataField="comment" SortExpression="comment" HeaderText="Comment" HeaderStyle-VerticalAlign="Top"/>
           <asp:BoundField DataField="brandcategoryname" SortExpression="brandcategoryname" HeaderText="Brand Category" HeaderStyle-VerticalAlign="Top"/>
           <asp:BoundField DataField="commentdate" SortExpression="commentdate" HeaderText="Comment Date" HeaderStyle-VerticalAlign="Top"/>
       </columns>



它给出一个错误说:
XML Parsing Error: no element found

知道我哪里出错了吗?

在此先感谢



It gives an error saying:
XML Parsing Error: no element found

Any idea where I''m going wrong?

Thanks in advance

推荐答案

从错误看来,好像标记(您的.aspx文件的代码)有问题.此外,您将您的网格绑定到arraylist,我认为它将不会公开属性(noticeid).
我建议您查看标记,并尝试使用可以公开必需属性的东西绑定网格(改为尝试使用DataTable).
From the error it looks as if there is a problem with the markup (your .aspx file''s code). Further you are binding your grid to an arraylist which I think won''t expose a property (noticeid).
I suggest you to look at your markup and try to bind the grid with something which can expose required property (try DataTable instead).


这篇关于将Objectdatasource绑定到网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆