How to append data in datagrid [Resolved]

Posted by Mayankshri under ASP.NET on 2/24/2012 | Points: 10 | Views : 1134 | Status : [Member] | Replies : 2
Hi, i want to append the data in data grid from data set or data table.

i am using this code but it overrides the previous data.

{
string startdate = "";
//string todate = "";
DataTable objDt = null;

try
{
DateTime fromdate = DateTime.Parse(txtfromdate.Text.Trim());
DateTime todate = DateTime.Parse(txttodate.Text.Trim());
TimeSpan ts = todate.Subtract(fromdate);
string i = ts.Days.ToString();
int[] values = new int[Convert.ToInt32(i)];

for (int j = 0; j <= Convert.ToInt32(i); j++)
{
fromdate = fromdate.AddDays(j);

DBClass objDBClass = new DBClass();
objDt = new DataTable();
//DateTime start = DateTime.Parse(txtfromdate.Text.Trim());
startdate = fromdate.ToString("yyyy/MM/dd");
objDt = objDBClass.Getdefaulterlist(startdate);

if (objDt.Rows.Count > 0)
{

dgdefaulertlist.DataSource = objDt;

dgdefaulertlist.DataBind();


}
else
{
lblmsg.Text = "No Record Found";
dgdefaulertlist.DataSource = null;
dgdefaulertlist.DataBind();
}
fromdate =DateTime.Parse(txtfromdate.Text.Trim());
}
}


Thanks in Advanace




Responses

Posted by: Mayankshri on: 2/24/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
datatable dt = new datatable();
datatable dt1 = new datatable():
dt.merge(dt1);

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

Posted by: Blessyjees on: 2/24/2012 [Member] Bronze | Points: 25

Up
0
Down
hi,
You should add new data to the existing datatable and bind that to te grid.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

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

Login to post response