OK....Thanks for the reply guys....Here are the problems I'm
having......I tried two things and neither work....I'll post twice so
its easier.....He is the first problem
Here is the gridview code:
<asp:GridView ID="custGrid" runat="server" AutoGenerateColumns="False"
BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3" OnRowDataBound="RowDataBound" OnRowEditing="RowEdit"
OnRowCancelingEdit="RowCancel" OnRowUpdating="RowUpdate"
OnRowDeleting="RowDelete" Style="position: static">
<FooterStyle BackColor="White" ForeColor="#000066" />
<Columns>
<asp:CommandField ButtonType="Button"
ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" />
<asp:BoundField DataField="Email" HeaderText="Email" / <asp:BoundField DataField="Password"
HeaderText="Password" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="Company">
<EditItemTemplate>
<asp
ropDownList ID="comp_lst" runat="server"
Text='<%# Bind("Customer") %>'></asp
ropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<
%# Bind("Customer") %>'></asp:Label>
</ItemTemplate>
</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066"
HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True"
ForeColor="White" />
</asp:GridView>
Then in the C# code I use this:
protected void RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList comp =
(DropDownList)e.Row.FindControl("comp_lst");
if (comp != null)
{
comp.Items.Add("test");
comp.SelectedValue = "test";
}
}
}
At this point I'm just trying to add one stupid test value into the
dropdownlist. When I view the page, originally the gridview shows up
fine. When I click the edit button I get this error: "Error loading
customers: 'comp_lst' has a SelectedValue which is invalid because it
does not exist in the list of items. Parameter name: value"