Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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

SQL DataSource
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductName], [SupplierID] FROM [Products]"></asp:SqlDataSource> 

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.
 
Share this answer
 
Comments
nwaf 3-Mar-13 7:04am    
thank you. this solution is easy and work
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900