How to merge two tables and displayed in single grid view?

aswinialuri-19361
Posted by aswinialuri-19361 under ASP.NET category on | Points: 40 | Views : 908
code in .aspx page:

drag and drop single grid view.

code in .aspx.cs page:

public partial class Mergegridview : System.Web.UI.Page
{
string strcon = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
binddata();

}
public void binddata()
{
SqlConnection con = new SqlConnection(strcon);
SqlDataAdapter da1 = new SqlDataAdapter("select * from stu",con);
SqlDataAdapter da2 = new SqlDataAdapter("select * from stu1", con);
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
da1.Fill(ds1,"Record");
da2.Fill(ds2,"Record");
ds1.Merge(ds2);
GridView1.DataSource = ds1;
GridView1.DataBind();
}
}

Comments or Responses

Login to post response