telerik rad grid data bind不显示数据

时间:2012-07-09 15:27:39

标签: vb.net datagrid telerik rad

当我在Binddata()上放置一个断点时,查询返回表中的所有数据。只有这是它没有绑定到网格。我错过了什么?我的代码出了什么问题?

<telerik:radgrid id="rdDisplayProducts" runat="server" allowpaging="true" 
allowsorting="true" autogeneratecolumns="False" enableajax="True" 
enableembeddedskins="false" onneeddatasource="bindData" 
pagerstyle-alwaysvisible="true" skin="txstate" visible="false" width="95%">
<exportsettings excel-fileextension=".xls" excel-format="Html" 
exportonlydata="True" filename="TxState_Activities" 
hidestructurecolumns="false" ignorepaging="true" openinnewwindow="true" 
pdf-allowcopy="true" pdf-allowprinting="true" pdf-fonttype="Embed" 
pdf-pagetitle="TxState_Activities" pdf-subject="TxState_Activities">
</exportsettings>
<statusbarsettings loadingtext="...Loading Data" readytext="Ready" />
<mastertableview allowpaging="true" allowsorting="true" 
commanditemdisplay="Top" 
commanditemsettings-exporttoexceltext="Export To Excel" 
commanditemsettings-exporttopdftext="Export To Pdf" 
commanditemsettings-exporttowordtext="Export To MS Word" 
commanditemsettings-showaddnewrecordbutton="false" 
commanditemsettings-showexporttoexcelbutton="true" 
commanditemsettings-showexporttopdfbutton="false" 
commanditemsettings-showexporttowordbutton="true" 
commanditemsettings-showrefreshbutton="false" datakeynames="Id" 
hierarchyloadmode="ServerOnDemand" nomasterrecordstext="No Records Exist" 
showfooter="false" showheader="true" showheaderswhennorecords="false" 
viewstatemode="Enabled">
    <telerik:Columns>
        <telerik:gridboundcolumn datafield="Id" headerstyle-horizontalalign="Center" 
            headertext="Id" itemstyle-horizontalalign="Center" />
        <telerik:gridboundcolumn datafield="Name" headerstyle-horizontalalign="Center" 
            headertext="Product&lt;br /&gt;Name" itemstyle-horizontalalign="Center" />
        <telerik:gridboundcolumn datafield="Description" headerstyle-   horizontalalign="Center" 
            headertext="Product&lt;br /&gt;Description" itemstyle-horizontalalign="Center" />


    </telerik:Columns>

    <detailtables>
        <telerik:gridtableview datakeynames="rqId" frame="LHS" 
          hierarchyloadmode="ServerOnDemand" name="RequestDetails">
            <Columns>
                <telerik:gridtemplatecolumn headertext="" uniquename="RequestRowItem">
                    <ItemTemplate>

                        <asp:Label ID="Label2" runat="server" CssClass="label label2" 
                            Text="Id: " />
                        <asp:Label ID="lblProductId" runat="server" CssClass="genericControl" 
                            Text='<%#Bind("Id")  %>' /><br /> 
                        <asp:Label ID="Label3" runat="server" CssClass="label label2" 
                            Text="Product Name:" />
                        <asp:Label ID="Label4" runat="server" CssClass="genericControl" 
                            Text='<%#Bind("Name") %>' Width="200px" /><br />
                        <asp:Label ID="Label5" runat="server" CssClass="label label2" 
                            Text="Description:" />
                        <asp:Label ID="Label6" runat="server" CssClass="genericControl" 
                            Text='<%#Bind("Description") %>' Width="200px" /><br />

                    </ItemTemplate>
                    </telerik:gridtemplatecolumn>
            </Columns>
         </telerik:gridtableview>
    </detailtables>
</mastertableview> 

VB内部

 Protected Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        rdDisplayProducts.Visible = True
        bindData()
        rdDisplayProducts.DataBind()


End Sub


      Protected Sub bindData()
        Using dc1 As New NewTestSiteDataClassesDataContext()

            Dim query = (From queryItem In dc1.Products Select queryItem)
            Dim queryResults = (From queryItem In query Select queryItem).ToList()

            If queryResults.Any Then
                rdDisplayProducts.Visible = True
                rdDisplayProducts.DataSource = queryResults
            Else
                lblSystemMessage.Text = "No results returned"
                rdDisplayProducts.Visible = False
            End If
        End Using

    End Sub

        Protected Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        rdDisplayProducts.Visible = True
        bindData()
        rdDisplayProducts.DataBind()
    End Sub
End Class

0 个答案:

没有答案