Pretty new to infragistics. i am using asp.net web forms
i have a wdg that is editable. For one of the columns, i would like to have a dropdown list.
i have tried both templates and providers, with limited success. Which is best for my application ?
the column in the grid is supervisor_emp_id
the dropdown is populated with emp_id and name
There is a similar forum post where I have provided an answer to the question. To sum it up you would need to use the ItemTemplate of the dropdown and use another WebDataGrid inside it, which is used as a multi-column dropdown, when the user selects a row the RowSelectionChanged event is used to set the value of the dropdown. There is also a small sample application that demonstrates how this could be achieved, below you can find the link for the forum post:
Please let me know if you need any further assistance.
Regards, Ivan Kitanov
I have got this working from another example. I populate the dropdown server side onrowinit.
it seems to work.
<ig:TemplateDataField Key="tloge_sci" Width="90px" Header-Text="USI/SCI"> <ItemTemplate> <ig:WebDropDown ID="wdd_sci" runat="server" TextField="sci_id" Width="80px" DataKeyFields="sci_id" AutoSelectOnMatch="true" EnableAutoCompleteFirstMatch="False" EnableClosingDropDownOnSelect="true">
<ClientEvents ValueChanged="SCI_ValueChanged" />
<HeaderTemplate> <table id="TemplateContainer"> <tr class="igg_row"> <td class="igg_HeaderCaption" style="width: 90px;">USI/SCI</td> <td class="igg_HeaderCaption" style="width: 500px;">Description</td> </tr> </table> </HeaderTemplate> <ItemTemplate> <table style="width: 100%" cellspacing="0" cellpadding="4"> <tr class="igg_row"> <td style="width: 100px;"> <%# DataBinder.Eval(Container.DataItem, "sci_id")%> </td> <td style="width: 500px;"> <%# DataBinder.Eval(Container.DataItem, "description")%> </td> </tr> </table> </ItemTemplate> </ig:WebDropDown> </ItemTemplate> </ig:TemplateDataField>
I have created a sample that follows your approach that uses a TemplatedField with WebDropDown, which uses tables to display multiple columns. In order to access the data source of the WebDropDown and set the value of a field based on the selection that the user has made, I recommend you serializing the data to a JSON string and then extracting the needed data based on the index of the selected item. The serializing could be done with the help of the following method:
public string ConvertDataTabletoString()
DataTable dt = (DataTable)Session["DS"];
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in dt.Rows)
row = new Dictionary<string, object>();
foreach (DataColumn col in dt.Columns)
I was able to reproduce the behavior, where the grid doesn’t enter edit mode on the TemplatedField, I would need some more time to investigate what might be causing this. If you would like to move enter edit mode to another field the following line could be used:
You can find the sample attached below. Please test it on your side and let me know if you have any questions.
Thanks. Good info. I think i will use a ajax call to retrieve value rather
than have all table data in json string
It seems wasteful to save data in session vars ? that is a lot of strain
on the web server. I notice other samples do this too. Is this necessary ?
I do notice odd behavior when playing with viewstate. Unable to go into
edit mode after saving. Nothing in dropdowns
Are there any good articles on this ?
Thanks for your help
It is not necessary to use Sessions variables, the reason why most of the samples use them is for simplicity.
Below you can find a page in our documentation regarding the EnableDataViewState and how it affects the functionalities:
In addition to this, in the following page there is an Infragistics article about DataViewState vs ViewState, while using the WebDataGrid, on the left side there is a section with many other articles related to the WebDataGrid.
There is also a general article that goes in depth about the ViewState, which you can find here:
Awesome. Thanks for your help.
using editorproviders is better because you can retrieve values very easily. Using templates,
you need to trap value changed and save it somewhere for retrieval
I’m glad I was able to help.
In case you need to look up at any of our client-side objects, methods, properties etc. here is a list with all the libraries of our ASP.NET AJAX CSOM:
Regards, Ivan Kitanov