Hi,
The DropDown menu in my GridView is only returning the first value.
Here is my code:
On button click event in gridview the row property is updated but DropDownMenu is returning first value
C# coding
The DropDown menu in my GridView is only returning the first value.
Here is my code:
Code:
<asp:GridView ID="GridView1" CssClass = "Grid" runat="server"
OnRowDataBound="OnRowDataBound" OnRowCommand="OnRowCommand"
BackColor="White" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3" Height="172px"
Width="1314px" AutoGenerateColumns="False" >
<asp:TemplateField HeaderText="Select Month">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" DataValueField = "Value" runat="server" >
<asp:ListItem Value="January">January</asp:ListItem> <asp:ListItem Value="February">February</asp:ListItem> <asp:ListItem Value="March">March</asp:ListItem> <asp:ListItem>April</asp:ListItem> <asp:ListItem>May</asp:ListItem> <asp:ListItem>June</asp:ListItem> <asp:ListItem>July</asp:ListItem> <asp:ListItem>August</asp:ListItem> <asp:ListItem>September</asp:ListItem> <asp:ListItem>October</asp:ListItem> <asp:ListItem>November</asp:ListItem> <asp:ListItem>December</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
C# coding
Code:
protected void OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Sub")
{
;
string Mont = ((DropDownList)GridView1.SelectedRow.FindControl("DropDownList1")).SelectedItem.ToString();
}
Comment