I'm assuming you have the gridview and it's databound. Click on the smart tag and edit columns. Click on the field you want to be a dropdown (from the Selected Fields listbox) and then select 'Convert this field into a TemplateField'.
Drop to markup view and then edit the template. For the EditItemTemplate you're going to want something like this:
The key is the SelectedValue piece. Binding to a field in your data source allows .NET to do the dirty work for you.
Alternatively, your DDL could also be databound, like when you're populating the list from another table in the database (categories, for example). If this is the case, just create that control (allow the UI to do it for you), setup the datasource for it, and make sure you drop back to markup view and edit the SelectedValue (Text and Value should be set by the wizard).
your code may fit asp.net datagrid control (web control) i guess he talk about windows forms , because if its asp.net he would ask it in the asp forums http://forums.asp.net
comboboxcolumn in datagridview
double americano
Hey there.
I'm assuming you have the gridview and it's databound. Click on the smart tag and edit columns. Click on the field you want to be a dropdown (from the Selected Fields listbox) and then select 'Convert this field into a TemplateField'.
Drop to markup view and then edit the template. For the EditItemTemplate you're going to want something like this:
<EditItemTemplate><asp:DropDownList ID="dd1" runat="server" SelectedValue='<%# Bind("DayOfWeek") %>'>
<asp:ListItem Text="Sunday" Value="0"></asp:ListItem>
<asp:ListItem Text="Monday" Value="1"></asp:ListItem>
<asp:ListItem Text="Tuesday" Value="2"></asp:ListItem>
<asp:ListItem Text="Wednesday" Value="3"></asp:ListItem>
<asp:ListItem Text="Thursday" Value="4"></asp:ListItem>
<asp:ListItem Text="Friday" Value="5"></asp:ListItem>
<asp:ListItem Text="Saturday" Value="6"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
The key is the SelectedValue piece. Binding to a field in your data source allows .NET to do the dirty work for you.
Alternatively, your DDL could also be databound, like when you're populating the list from another table in the database (categories, for example). If this is the case, just create that control (allow the UI to do it for you), setup the datasource for it, and make sure you drop back to markup view and edit the SelectedValue (Text and Value should be set by the wizard).
Cheers,
jc
John Portnov
mmmmmm from what does your datagridview retrieve its data , is it bound to dataset, array, or what
best regards
Bloke
hi, james
your code may fit asp.net datagrid control (web control) i guess he talk about windows forms , because if its asp.net he would ask it in the asp forums http://forums.asp.net
best regards
aaguiar
my apologies, I'm eyeball deep in ASP.NET right now.
Cheers,
jc
afel
good luck with Asp.net, you will injoy it for sure
best regards