i want to display some column of table 2 as well as table1 in a single grid,,,
plz provide me code with example....
thanks..
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VasanthRank #1,487 · 1.1K reputationPosted Mar 24, 2010, 12:39 AM EDT
html> head> title>Datagrid sampletitle> head> body> form runat="server" ID="Form1"> asp:DataGrid ID="dgSample" EnableViewState="False" Runat="server" /> form> body> html>Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 24, 2010, 1:14 AM EDT
if you don't want to join the tables then you can do following:
Create a dataset fill it with data from table1...
Dataset ds=new DataSet();
adp.fill(ds);
now you can add columns to your dataset...
DataColumn dc=new DataColumn("Col_tabl2",System.Type.GetType("SystemString"));
ds.Columns.Add(dc);
now you add rows from table2 manually...
Get the data from Table 2 in datareader and add it to the specific column like this:
DataReader rdr=cmd.ExecuteReader();
for(int i=0;i
ds.Tables[0].Rows[i]["Col_tab2"]=rdr["Col_tab2"].ToString();
}
Similarly you can add more column and rows manually to your dataset and
finally bind your Grid.
Please mark as answer if it helps.