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
To Bind Two Or More Dropdown With Single Dataset In ASP.NET
Vandana
Aug 17
2016
Code
749
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
public
partial
class
Default2: System.Web.UI.Page {
string
ConnStr = ConfigurationManager.ConnectionStrings[
"CRMConnectionString"
].ToString();
SqlConnection con =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"CRMConnectionString"
].ToString());
DataSet someDataSet =
new
DataSet();
SqlDataAdapter adapt =
new
SqlDataAdapter();
protected
void
Page_Load(
object
sender, EventArgs e) {
if
(!IsPostBack) {}
binddataset();
TopTeam();
}
public
void
binddataset() {
con.Open();
SqlCommand comm1 =
new
SqlCommand(
"select distinct Agentname from crm_agentname where status='Active'"
, con);
SqlCommand comm2g =
new
SqlCommand(
"select distinct Teamname from crm_Teamname where status='Active'"
, con);
SqlCommand comm3g =
new
SqlCommand(
"select distinct Locationname from crm_location where status='Active'"
, con);
///////////////////AGENTNAME
someDataSet.Tables.Add(
"crm_agentname"
);
adapt.SelectCommand = comm1;
adapt.Fill(someDataSet.Tables[
"crm_agentname"
]);
ddlagent.DataTextField =
"Agentname"
;
ddlagent.DataValueField =
"Agentname"
;
ddlagent.DataSource = someDataSet.Tables[
"crm_agentname"
];
ddlagent.DataBind();
///////////////////Teamname
someDataSet.Tables.Add(
"crm_Teamname"
);
adapt.SelectCommand = comm2g;
adapt.Fill(someDataSet.Tables[
"crm_Teamname"
]);
ddlteam.DataTextField =
"Teamname"
;
ddlteam.DataValueField =
"Teamname"
;
ddlteam.DataSource = someDataSet.Tables[
"crm_Teamname"
];
ddlteam.DataBind();
///////////////////Location
someDataSet.Tables.Add(
"crm_location"
);
adapt.SelectCommand = comm3g;
adapt.Fill(someDataSet.Tables[
"crm_location"
]);
ddllocation.DataTextField =
"Locationname"
;
ddllocation.DataValueField =
"Locationname"
;
ddllocation.DataSource = someDataSet.Tables[
"crm_location"
];
ddllocation.DataBind();
con.Close();
}
}
ASP.NET
Bind Dropdown