【问题标题】:use two radgridview to display data使用两个radgridview显示数据
【发布时间】:2013-07-30 17:33:14
【问题描述】:

我创建 radlistview1 包含 radlistview2

<telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="cg_id" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            thong tin loai
            <telerik:RadListView ID="RadListView2" runat="server" DataKeyNames="cg_id" DataSourceID="SqlDataSource2">
        <ItemTemplate>
            <%#Eval("cg_id") %>
        </ItemTemplate>
    </telerik:RadListView>        
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TravelConnectionString %>" SelectCommand="SELECT cg_id, cg_name, cg_size, cg_soluongcay, cg_tongtichluydai FROM Categorys_Group WHERE (cg_id = @id)">
        <SelectParameters>
            <asp:SessionParameter Name="id" SessionField="id" DefaultValue='1' />
        </SelectParameters>
    </asp:SqlDataSource>
        </ItemTemplate>
    </telerik:RadListView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TravelConnectionString %>" SelectCommand="SELECT * FROM [Categorys_Group]"></asp:SqlDataSource>

如你所见。 radlistview2 使用 SqlDataSource2。现在,我想从 radlistview1 () 获取值的 asp:SessionParameter defaultvalue,但它出错了。

<asp:SessionParameter Name="id" SessionField="id" DefaultValue='<%#Eval("cg_id") %>' />

我的目标是使用 2 radlistview。 radlistview1 包含 radlistview2radlistview2 将显示 ID 为 radlistview1 的数据。

谁能帮帮我?

感谢您的阅读。

【问题讨论】:

  • 这里有错误吗?我建议,你最好把你的sqldatasourse写在listView之外!
  • 我不在 radlistview1 之外使用 sqldatasourse2。因为我想设置值 Session["id"] = 每次 radlistview1 创建项目时获取 radlistview1 的值。

标签: asp.net telerik


【解决方案1】:

把你的SqlDataSource2改成

 <asp:SqlDataSource ID="SqlDataSource2" runat="server"  
 ConnectionString="<%$ ConnectionStrings:TravelConnectionString %>"  
 SelectCommand='SELECT cg_id, cg_name, cg_size, cg_soluongcay, cg_tongtichluydai  
                FROM Categorys_Group WHERE (cg_id = <%# Eval("cg_id") %>)' >

此代码不需要使用sessionParameter

如果您想使用参数,请将您的sessionParameter 更改为Parameter 喜欢

<asp:Parameter  DefaultValue='<%# Eval("cg_id") %>)' Type="Int32" Name="id"/>

祝你好运:)

【讨论】:

  • 首先感谢您的帮助。我做了两种方法,但都有错误。在代码中不需要使用 sessionParameter 。错误:“)' Type="Int32" Name="id"/> 错误:数据绑定表达式仅在具有 DataBinding 事件的对象上受支持. System.Web.UI.WebControls.Parameter 没有 DataBinding 事件。
  • 为什么 的默认值没有得到值 当将 更改为 1 或 2 ... 成功。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-25
  • 2019-05-18
  • 2022-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多