Hi,
I've a gridview and a radiobuttonlist
<asp:GridView ID="GridView1" runat="server" AutoGenerateSelectButton="True">
<Columns>
<asp:TemplateField HeaderText="IsApproved">
<ItemTemplate>
<asp:CheckBox ID="chkApproved" runat="server" CommandName="Approve" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Approve" Value="1"></asp:ListItem>
<asp:ListItem Text="Reject" Value="2"></asp:ListItem>
</asp:RadioButtonList>
Gridview has a datasource that has four columns. Now on button click I want to insert the gridview data in the database, how to access the data in the columns,
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == "1")
{
foreach (GridView row in GridView1.Rows)
{
var chk = row.FindControl("chkApproved") as CheckBox;
if (chk.Checked)
{
DataSet1TableAdapters.tbl_ApproveTableAdapter ta = new DataSet1TableAdapters.tbl_ApproveTableAdapter();
ta.Insert(*WHT TO WRITE HERE*);// TO access each column of tht particular row
}
}
}
}