5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 03 Mar 2010, 05:45 AM
Hello Tim,
The following documentation will help yuou in customizing the GridDropdownColumn. In the ItemDataBound event, access the dropdownlist control and set the DataSource.
Checkout the link: Customize/Configure GridDropDownColumn
-Shinu.
The following documentation will help yuou in customizing the GridDropdownColumn. In the ItemDataBound event, access the dropdownlist control and set the DataSource.
Checkout the link: Customize/Configure GridDropDownColumn
-Shinu.
0
tim
Top achievements
Rank 1
answered on 04 Mar 2010, 04:43 PM
Thank you. I tried to replicate the sample http://www.telerik.com/help/aspnet-ajax/grdoperationswithdropdownlistinedititemtemplate.html with no luck. Here's my code.
And code behind.
I have a breakpoint at Grid1_NeedDataSource, but I am not getting there. Grid1_NeedDataSource is not being called.
Thanks,
Tim
| <telerik:RadGrid ID="Grid1" AutoGenerateColumns="false" runat="server" Width="90%"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn HeaderText="" UniqueName="WDFields" DataField="friendlyname" /> |
| <telerik:GridTemplateColumn UniqueName="ddHeader" HeaderText="Header"> |
| <ItemTemplate> |
| <asp:DropDownList ID="HeaderDropDown" runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn HeaderText="Sample" DataField="values" UniqueName="Sample" /> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
And code behind.
| private void Grid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| DataTable param = ReadParam(); |
| Grid1.DataSource = param; |
| } |
| private void Grid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| List<string> header = ReadHeader(); |
| GridDataItem item = e.Item as GridDataItem; |
| DropDownList list = item.FindControl("HeaderDropDown") as DropDownList; |
| list.DataSource = header; |
| list.DataBind(); |
| } |
I have a breakpoint at Grid1_NeedDataSource, but I am not getting there. Grid1_NeedDataSource is not being called.
Thanks,
Tim
0
robertw102
Top achievements
Rank 1
answered on 04 Mar 2010, 08:10 PM
If the RadGrid markup you posted is correct. The reason the methods are not being called is because you didn't attach them to your grid. You'll notice that the event handlers are not set in the RadGrid declaration in your aspx page.
0
tim
Top achievements
Rank 1
answered on 04 Mar 2010, 08:14 PM
Here's the code from the sample I referenced (http://www.telerik.com/help/aspnet-ajax/grdoperationswithdropdownlistinedititemtemplate.html).
Where are the event handlers?
Where are the event handlers?
| <telerik:radgrid id="RadGrid1" runat="server" AutoGenerateColumns="False"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn UniqueName="ContactName" ReadOnly="True" HeaderText="ContactName" |
| DataField= "ContactName" /> |
| <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Country"> |
| <ItemTemplate> |
| <asp:Label id="Label1" runat="server"> |
| <%# DataBinder.Eval(Container.DataItem, "Country") %> |
| </asp:Label> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <asp:DropDownList id="List1" runat="server" /> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" /> |
| </Columns> |
| </MasterTableView> |
| </telerik:radgrid> |
0
tim
Top achievements
Rank 1
answered on 04 Mar 2010, 09:28 PM
Ah, needed to add,
| private void Page_Load(object sender, EventArgs e) |
| { |
| Grid1.NeedDataSource += new GridNeedDataSourceEventHandler(Grid1_NeedDataSource); |
| Grid1.ItemDataBound += new GridItemEventHandler(Grid1_ItemDataBound); |
| } |