how to create editable combobox inside a templatecolumn of datagrid

Posted by Raj_Chennai under WPF on 12/4/2013 | Points: 10 | Views : 2495 | Status : [Member] | Replies : 3
i need to create editable combobox inside template column of datagrid...when the user add new item which is not there in database should be updated to database else if I select the value from combobox then the selected value is to be updated

raj


Responses

Posted by: vishalneeraj-24503 on: 12/5/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
You can take dropdownlist inside Itemtemplate or EditItemTemplate as shown:-

<asp:GridView ID="grid_view_employee_details" runat="server" AllowPaging="true" AutoGenerateColumns="false"
OnRowDataBound="grid_view_employee_details_RowDataBound" OnSelectedIndexChanged ="grid_view_employee_details_SelectedIndexChanged">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="ddl_employee_name" runat="server"></asp:DropDownList>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddl_edit_employee_name" runat="server"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

You can fill employee dropdownlist in Gridview RowdataBound event and button click,you can find your control.

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 12/5/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Also see:-
http://stackoverflow.com/questions/7764446/issue-with-populating-dropdownlist-in-gridview-edit-mode-in-c-sharp
http://stackoverflow.com/questions/833490/gridview-row-editing-dynamic-binding-to-a-dropdownlist
http://stackoverflow.com/questions/18656733/how-to-bind-asp-net-dropdownlist-control-in-edititemtemplate-of-gridview-on-edit
http://forums.asp.net/p/1604495/4089355.aspx
http://www.codeproject.com/Articles/23471/Editable-GridView-in-ASP-NET-2-0

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response