TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Binding Multiple DataSets in single GridView
Shridhar Sharma
Jul 22
2015
Code
7.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Default.aspx.rar
using
System;
using
System.Collections.Generic;
using
System.Data;
using
System.Data.SqlClient;
using
System.Data.Sql;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Configuration;
public
partial
class
_Default : System.Web.UI.Page
{
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"constr"
].ConnectionString);
SqlCommand cmd;
SqlDataAdapter sa;
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
//Binding GridView
Bind_Data_Grid();
}
protected
void
Bind_Data_Grid()
{
con.Open();
cmd =
new
SqlCommand(
"select * from Credentials"
, con);
sa =
new
SqlDataAdapter(cmd);
DataSet ds1 =
new
DataSet();
sa.Fill(ds1);
cmd =
new
SqlCommand(
"select * from tblLocation"
, con);
sa =
new
SqlDataAdapter(cmd);
DataSet ds2 =
new
DataSet();
sa.Fill(ds2);
//Merge two DataSets
ds1.Merge(ds2);
DataGrid.DataSource = ds1.Tables[0].DefaultView;
DataGrid.DataBind();
con.Close();
}
}
Gridview binding
dataset
ASP.NET