Click here to Skip to main content
15,909,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,


I am retrieving data from database and bind to dynamic gridview.

My problem is

I am retrieving class details on the basis of teacher names,but the o/p will bind in not proper way can u please solve my problem.

datatable dx = dk.Tables[0];

dx have some data


datatable df=dc.Table[0];

df have another data and it bind to dynamic gridview. It does't display in properway.

I am writing loop like this

C#
int columnIndex = 1;
           DataColumn newColumn = dx.Columns.Add(tim1, typeof(string));
           int newColumnIndex = dx.Columns.IndexOf(newColumn);
           for (int x = 0; x < df.Columns.Count; x++)
           {
               dx.Rows[x][newColumnIndex] = df.Rows[x][columnIndex];
           }
      
       GridView3.DataSource = dx;
       GridView3.DataBind();
Posted
Comments
Avik Ghosh22 7-Feb-13 4:31am    
datatable dx = dk.Tables[0]; change to dataset....
dataset dx = dk.Tables[0];
dataset df=dc.Table[0];

datatable dx = dk.Tables[0];
change to dataset....
dataset dx = dk.Tables[0]; dataset df=dc.Table[0];
 
Share this answer
 
Suppose If I changed datatable to dataset in loop here
" DataColumn newColumn = dx.Columns.Add(tim1, typeof(string));"

getting some error
 
Share this answer
 
Comments
Avik Ghosh22 7-Feb-13 4:48am    
dx.Tables[0].Columns.Add(tim1, typeof(string));
try this...
Avik Ghosh22 7-Feb-13 5:09am    
how do u solve this problem ....??
No Sir,
I changed as u send like this but same o/p will be displayed
 
Share this answer
 

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