Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
To Bind Two Or More Dropdown With Single Dataset In ASP.NET
WhatsApp
Vandana
Aug 17
2016
889
0
1
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
Up Next
To Bind Two Or More Dropdown With Single Dataset In ASP.NET