hello,
my sql store producer return three table at a time
and i got these all table in my one dataset
so how i bind this dataset all table in my gridview
All table sturecture are same
so plese give me some code or idea for that
and tell me if not do in c# then tell me how combine this three table in to one
my this tables come base on cursor based
so thats why come more then one table
thanks
Loading

Jignesh TrivediPosted Jan 3, 2012, 5:00 AM
DataSet d = new DataSet(); // write your existing retrieving code.
DataTable dt = d.Tables[0];
for (var i = 1; i < d.Tables.Count; i++)
{
dt.Rows.Add(d.Tables[i].Rows);
}
GridView1.DataSource = ds1;
GridView1.DataBind();
hope this help.
Satyapriya NayakPosted Jan 2, 2012, 10:42 PM
Note structure of 3 tables and there data type should be same.
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds1;
string str;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
void BindGrid()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from t1 UNION select * from t2 UNION select * from t3";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds1 = new DataSet();
sqlda.Fill(ds1);
GridView1.DataSource = ds1;
GridView1.DataBind();
con.Close();
}
}
Thanks