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
poonam tyagi
NA
5
3.4k
how can fill dataset by gridview in c# .net
Aug 12 2014 10:44 AM
how can fill datatable by gridview with c# i m applying that code but that error occur Input array is longer than the number of columns in this table. my code is that
private void button4_Click(object sender, EventArgs e)
private void button4_Click(object sender, EventArgs e)
{
{
DataSet d = new DataSet();
DataTable dt = new DataTable();
// add the columns to the datatable
//if (dataGridView4.Rows.Count!=null)
//{
for (int i = 0; i < dataGridView4.Rows.Count-1; i++)
{
//for (int j = 0; j < dataGridView4.Columns.Count; i++)
//{
//for (int i = 0; i < dataGridView4.HeaderRow.Cells.Count; i++)
//{
dt.Rows.Add(dataGridView4.Rows[i].Cells[0].Selected.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[1].Selected.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[2].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[3].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[13].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[18].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[19].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[21].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[22].Value.ToString());
dt.Rows.Add(dataGridView4.Rows[i].Cells[23].Value.ToString());
da = new OleDbDataAdapter();
da.Fill(d, "dt");
}
Reply
Answers (
2
)
c#.net
TreeView Falickering Problem