hi,
Datagridview have 50 column(these columns name is 1 to 50), need to database cycle out of the value stored in the corresponding column(Table there are 4 column stored value is also digital )
demoNUM table Data as follows:
SELECT * FROM demoNUM;
result:
r_1 r_2 r_3 r_4
1 2 4 50
1 2 3 5
2 3 5 50
Below is the effect of imitation:
datagridview columns name: 1 2 3 4 5 .....50
rows: 1 2 4 50
1 2 3 5
2 3 5 50
thanks
Loading


VulpesRank #55 · 29.2K reputationPosted Aug 22, 2012, 9:46 AM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 19, 2012, 9:26 AM EDT
The code to populate the DGV's rows will then be:
dataGridView1.RowCount = dt.Rows.Count;
for(int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
for(int j = 0; j < 4; j++)
{
int k = int.Parse(dr[j].ToString());
dataGridView1.Rows[i].Cells[k - 1].Value = k;
}
}
Ken HRank #2,315 · 610 reputationPosted Aug 19, 2012, 4:57 PM EDT
i do't know how to upload attachments in here,I'd like to upload attachments may let you know some.
thanks
VulpesRank #55 · 29.2K reputationPosted Aug 20, 2012, 12:58 AM EDT
Nattudurai EswaramurthyRank #5,536 · 296 reputationPosted Aug 20, 2012, 1:41 AM EDT
its simple. Just look through all the rows and select a each column for the row for example
and do appropriately.
eg.
for(int i=0;i< GridView1.Rows.count;i++)
{
GridView1.Rows[i].Cells[0].Value
}
VulpesRank #55 · 29.2K reputationPosted Aug 22, 2012, 2:09 AM EDT
Ken HRank #2,315 · 610 reputationPosted Aug 22, 2012, 4:23 PM EDT
Ken HRank #2,315 · 610 reputationPosted Aug 23, 2012, 9:58 PM EDT
thanks
VulpesRank #55 · 29.2K reputationPosted Aug 24, 2012, 2:57 AM EDT
Try it like this: