when i run as follows in datagridview in windows applciation
Course GS VB SJ RK MS(faculty) Total
REO 10
AFF 10
total number of faculty is 5
total hours of course is 10
when i divide the total(10) by number of faculty (5) and give the answer 2.
i want to display the 2 for each faculty GS,VB,SJ,RK,Ms.
i want the output as follows;
i have one Load Button
Course GS VB SJ RK MS(faculty) Total
REO 2 2 2 2 2 10
AFF 2 2 2 2 2 10
when click the Load button 2 has to displayed in datagridview for each faculty.
for that i have using this formula, total (10) is divide by number of faculty(5) gives the answer 2
kindly please help me,how can i do?
Thanks and regards,
Rao.
Loading
Jignesh TrivediPosted Feb 17, 2013, 10:51 PM
hi,
In data grid, to update any value you just update Data Source.
for example if you bind data grid with DataTable then you just update data Table
example;
private void button1_Click(object sender, EventArgs e)
{
DataTable dTable = dataGridView1.DataSource as DataTable;
if (dTable != null)
{
foreach (DataRow dRow in dTable.Rows)
{
var total = Convert.ToInt32(dRow["Total"]) / 5;
dRow["GS"] = total;
dRow["VB"] = total;
dRow["SJ"] = total;
dRow["RK"] = total;
dRow["MS"] = total;
}
}
}
you can try this code by replacing Name of data grid and column binded.
hope this will help you.