Hi Folks
every where i find code for putting dropdownlists in all the cells of a particular column
But i dont find code anywhere on this planet to make only one cell of a column have dropdownlist and other cells have no dropdown.
If anyone knows how to do it, pls reply.
thanks in advance.
Indeed, this is a good idea and could work. Another approach that might be applicable in this situation is to hook the grid InitializeRow event and to find the dropdownlist directly from there (I assume that the dropdown will be placed in a templated column):
TemplatedColumn col = (TemplatedColumn)e.Row.Cells.FromKey("dropDownContainer").Column;CellItem ci = (CellItem)col.CellItems[e.Row.Index];DropDownList archive = (LinkButton)ci.FindControl("dropDownListID");
At the risk of asking what should be obvious: Couldn't you put both a DropDownList and a TextBox in the template, and use your array value to determine which one is visible and which one isn't.
Hi Mr.Stankov,
Thanks for your solution. Your solution is very good, but it does not fit into my case.
My case is as follows:
I read a array of some integer contents.
depending upon the value of the integer have to make the cell editable(normal) or editable(dropdownlist)
if the array is 0 i have to make the cell editable(normal)
else if array is 1 i have to make cell editable(dropdownlist) and populate the dropdownlist with three items at runtime.
The main constraint here is doing thing at runtime,
so please help me on this Mr.Stankov.
Does UltraWebGrid allow making single cells have dropdownlist or normal edit at runtime
Thanks in advance.
You can hook custom event handlers in the various events of the nested controls inside the template and hide/show/populate them based on certain criteria. In the example below. I am hiding all dropdowns with the exception of the dropdown in the third row:
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Height="200px" Width="325px" DataSourceID="AccessDataSource1" > <Bands> <igtbl:UltraGridBand> <Columns> <igtbl:TemplatedColumn> <CellTemplate> <asp:DropDownList runat="server" ID="DropDownList1" OnInit="DropDownList1_OnInit"> </asp:DropDownList> </CellTemplate> </igtbl:TemplatedColumn> </Columns> </igtbl:UltraGridBand> </Bands> ...</igtbl:UltraWebGrid> protected void DropDownList1_OnInit(object sender, EventArgs e) { DropDownList dropDownList = sender as DropDownList; CellItem parentCell = (CellItem) dropDownList.NamingContainer; if (parentCell.Cell.Row.BandIndex != 3) { dropDownList.Visible = false; } }
Hope this helps.