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.
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.
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.
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");