This is a discussion on DropdownList in Editable Datagrid within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi, I m using the editable Datagrid . In the edit mode i have dropdown list . when i click the edit ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, I m using the editable Datagrid . In the edit mode i have dropdown list . when i click the edit function my dropdown should focus to the selected value. when i click the edit function my dropdown get focus in to first value . shaalini.s |
| Sponsored Links |
| |||
| hi , Try this <asp ataGrid id="DataGrid1" AutoGenerateColumns="False" ItemStyle-CssClass="cdb-AltRow" AlternatingItemStyle-CssClass="cdb-AltRow2" DataKeyField="ProductID" OnUpdateCommand="DataGrid1_Update" OnEditCommand="DataGrid1_Edit" OnCancelCommand="DataGrid1_Cancel" runat="server"> <Columns> <asp:TemplateColumn HeaderText="Discontinued"> <ItemTemplate> <asp:Label ID="lblDiscontinued" Text='<%#ShowVal(Convert.ToBoolean( DataBinder.Eval(Container.DataItem, "Discontinued").ToString()) )%>' Runat="server" /> </ItemTemplate> <EditItemTemplate> <asp:Label runat="server" id="lblProductID" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem, "ProductId") %>'/> <asp:Label ID="lblEditDiscontinued" Text='<%#ShowVal(Convert.ToBoolean( DataBinder.Eval(Container.DataItem, "Discontinued").ToString() ))%>' Runat="server" /> <asp ropDownList id="ddlDiscontinued" DataSource="<%# BindTheDiscontinued() %>" OnPreRender="SetDropDownIndex" DataTextField="Discontinued" DataValueField="Discontinued" runat="server" /> </EditItemTemplate> </asp:TemplateColumn> <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" ItemStyle-Width="100px" HeaderText="Commands" /> </Columns> </asp ataGrid>Code Behind string strDiscontinued; public void DataGrid1_Edit(Object sender, DataGridCommandEventArgs e) { strDiscontinued = ((Label )e.Item.FindControl("lblDiscontinued")).Text; DataGrid1.EditItemIndex = (int)e.Item.ItemIndex; BindGrid(); } protected void SetDropDownIndex(Object sender ,System.EventArgs e ) { DropDownList ed ; ed = (DropDownList) sender; ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(strDiscontinu ed)); } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create dropdownlist at runtime | shaalini | ASP and ASP.NET Programming | 1 | 02-14-2008 08:16 PM |
| how to bind values of onedropdownlist to another dropdownlist in another page? | poornima | ASP and ASP.NET Programming | 0 | 02-03-2008 09:07 PM |
| create Editable label without postback | shaalini | ASP and ASP.NET Programming | 4 | 10-18-2007 02:18 AM |
| Problem in my DropDownList SelectedIndexChanged. | S.Vinothkumar | ASP and ASP.NET Programming | 2 | 10-11-2007 11:47 PM |
| How to get the index value of the dropdown from the dropdownlist item | Sathish Kumar | C# Programming | 0 | 03-12-2007 12:14 PM |