Hello,
i have grid as
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Pune</asp:ListItem>
<asp:ListItem>Banglore</asp:ListItem>
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Mumbai</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>Pune</asp:ListItem>
<asp:ListItem>Banglore</asp:ListItem>
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Mumbai</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="H0">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="H1">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" Text="ADD" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Clear" onclick="Button2_Click" />
when i click on add it adds a row to grid as
static DataTable dt = new DataTable();
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
when i click on add button to add second row the values from first row get vanished. So how i can maintain the viewstate for those controls
thanx in advance