To edit a value in ASP.NET 2.0 gridview control you have more options than only a textbox. If you want to choose of a valuelist you can take a dropdownlist. The data of dropdown comes usaly from a table and is placed in the edititemtemplate. A second SQLDatasource control gets the data (here named DSPLZ). The binding is done by selectedValue
<EditItemTemplate> <asp:SqlDataSource ID="DSKonf" runat="server" ConnectionString="<%$ ConnectionStrings:EventsConnectionString %>"
SelectCommand="SELECT * FROM [AktuelleKonfSteuerung]"></asp:SqlDataSource> </EditItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="DSPLZ" DataTextField="PLZ" DataValueField="PLZ" SelectedValue='<%# Bind("adressplz") %>'> </asp:DropDownList> .. The problems come if the data in the table doesnt fit your data in the PLZ table. Most common reason is that the field contains a NULL Value. Bind fails!
The trick is that you can add items to the dropdown list by declaration. The second part of the trick is to add the DB entrys to the declarated entrys by AppenddataboundItems. Take care to set the value to "" cause the bind gives also back a "" if the field contains NULL
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="DSPLZ" DataTextField="PLZ"
DataValueField="PLZ" SelectedValue='<%# Bind("shipPLZ") %>' AppendDataBoundItems=true> <asp:ListItem Text="wählen" Value=""></asp:ListItem> </asp:DropDownList> </asp:TemplateField>