Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to appned the gridview data with some more data .
i am using this code-
C#
{
        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());
            }
         } 

the data is override .i want to append the data .

Thanks in Advance
Posted
Comments
Career Web Helper 24-Feb-12 3:13am    
you want to merge DT vertically or Horizontally for binding to gv?
mayankshrivastava 24-Feb-12 3:15am    
vertically .........
there are two columns in gridview (date,employeename).i want to append them.

1 solution

add two data table.

C#
dt1.merge(dt2);
 
Share this answer
 
Comments
Career Web Helper 24-Feb-12 4:47am    
merge() doesn't merge DT's vertically...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900