gridview adding same row

Posted by Aruna under ASP.NET on 4/28/2010 | Views : 1287 | Status : [Member] | Replies : 1
Hi

I have a gridview with 5 column and 4 rows and one button outside the gridview.In the columns there is calender to insert the date if i click the button the same 5 column and rows should be dynamically added in the gridview , so that i can reenter the calender for the another employee.
below example

s.no empname dt of joining dt of leaving
1 empfriends dt of joining dt of leaving
1 empfriends dt of joining dt of leaving

button

after clicking button
my grid should come like this

s.no empname dt of joining dt of leaving
1 empfriends dt of joining dt of leaving
1 empfriends dt of joining dt of leaving
2 empfriends dt of joining dt of leaving
2 empfriends dt of joining dt of leaving
again clicking button it should go on adding and increasing the serial number


Thanks




Responses

Posted by: Pavanandey on: 4/28/2010 [Member] Bronze

Up
0
Down

Hi,

In this senario go for datatable , create colums of the datatable add as many row u want and assign the same to the gridview,
so u can keep adding row to datatable

DataTable Dt = new DataTable();
Dt.Columns.Add(new DataColumn("COL1", typeof(System.String)));
Dt.Columns.Add(new DataColumn("COL2", typeof(System.Double)));
Dt.Columns.Add(new DataColumn("COL3", typeof(System.String)));
Dt.Columns.Add(new DataColumn("COL4", typeof(System.String)));
Dt.Columns.Add(new DataColumn("COL5", typeof(System.String)));
Dt.Columns.Add(new DataColumn("COL6", typeof(System.String)));

GridView1.DataSource = Dt;
GridView1.DataBind();

Thanks
Pavan Kumar
Mark Answer if this fits the need

Aruna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response