将DropDownList添加到radGrid [英] Adding DropDownList to A radGrid

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

问题描述

嘿,

我正在使用ASP.net Ajax Rad网格,我想向其在单列Items上动态生成的每一行添加一个dropDownList,该列采用Database表中的值.

有人可以帮忙吗...

谢谢
Amit

Hey there,

I am using ASP.net Ajax Rad grid and i want to add a dropDownList to each of its rows generated dynamically on a single column Items which takes the values from Database table.

Can Someone help...

Thanks
Amit

推荐答案

对于.aspx
<rad:GridTemplateColumn HeaderText="Temp" UniqueName="Temp">
      <ItemTemplate>
          <asp:DropDownList ID="DropDownList1" runat="server">
          </asp:DropDownList>
      </ItemTemplate>
    </rad:GridTemplateColumn


SQL数据源


SQL DataSource

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%


ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductName], [SupplierID] FROM [Products]"></asp:SqlDataSource>
ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductName], [SupplierID] FROM [Products]"></asp:SqlDataSource>


CSharp代码


CSharp code

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if(e.Item is GridDataItem)
       {
        GridDataItem item=(GridDataItem)e.Item;
        DropDownList ddl = (DropDownList)item["Temp"].FindControl("DropDownList1");
        ddl.DataSourceID = "SqlDataSource1";
        ddl.DataTextField = "ProductName";
        ddl.DataValueField = "ProductName";
        ddl.DataBind();

       }
   }


如果有帮助,请 投票 接受答案 .


Please vote and Accept Answer if it Helped.


嗨 阿米特,

请尝试以下链接:
http://demos.telerik.com/aspnet-ajax/combobox/examples/功能/comboingrid/defaultcs.aspx [ ^ ]

如有任何疑问,请让我知道.

如果有帮助,请提供"投票",如果这是正确的答案,请提供"接受答案".

谢谢,
Imdadhusen
Hi Amit,

Please try the following link:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/comboingrid/defaultcs.aspx[^]

Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.

Thanks,
Imdadhusen


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

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