TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajkumar R
NA
183
220.1k
Bulk insert from gridview to database
Dec 5 2011 12:11 AM
i have a gridview that contain more than 100 records, in itemtemplate i have ackeckbox for eah row. Here i want to insert all checked checkbox row to the database
<asp:GridView ID="GridView1" runat="server" Width="96%" PageSize="10" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnRowCommand="GridView1_RowCommand" >
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkbox" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remark">
<ItemTemplate>
<asp:Label ID="lblremark" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
the above is the source code i have.
Code behind
protected void btnview_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TNVKP_8;Integrated Security=True");
con.Open();
DataSet reportData = new DataSet();
//reportData.ReadXml(Server.MapPath("test.xml"));
filename = System.IO.Path.GetExtension(FileUpload1.FileName.ToString());
if (filename == ".xml")
{
reportData.ReadXml(Server.MapPath(FileUpload1.FileName));
GridView1.DataSource = reportData;
GridView1.DataBind();
con.Close();
}
else
{
GridView1.Visible = false;
Response.Write("Invalid File");
}
}
the above code i have used to view the xml data in the gridview now i want to insert the gridview data in to database. Post solution for this
Thanks in advance
Reply
Answers (
3
)
SOLVED : Even rows on edit command (gridview) are marked as HeaderRow
Use of view state in ASP.NET