Multiple DataBinds off one DataSet

G

Guest

Hi I have typed out the following codebehind:
private void Page_Load(object sender, System.EventArgs e)
{
clubconn=new SqlConnection(strClubconn);
dsClub=new DataSet();

string strClubSelect="SELECT Club_tbl.ClubName, Club_tbl.ClubID FROM
Club_tbl ORDER BY Club_tbl.ClubID Desc";
string strPositionSelect="SELECT Position_tble.PositionID,
Position_tble.PositionName FROM Position_tble ORDER BY
Position_tble.PositionID Desc";
string strAccessSelect="SELECT AccessGroup_tbl.AccessID,
AccessGroup_tbl.UserAccess FROM AccessGroup_tbl ORDER BY
AccessGroup_tbl.AccessID Desc";
clubconn.Open();
clubadapt=new SqlDataAdapter(strClubSelect,clubconn);
clubadapt.Fill(dsClub,"Club");
clubadapt.SelectCommand=new SqlCommand(strPositionSelect,clubconn);
clubadapt.Fill(dsClub,"Position");
clubadapt.SelectCommand=new SqlCommand(strAccessSelect,clubconn);
clubadapt.Fill(dsClub,"Access");
clubconn.Close();

Org.DataSource=dsClub;
Org.DataValueField=dsClub.Tables["Club"].Columns[1].ToString();
Org.DataTextField=dsClub.Tables["Club"].Columns[0].ToString();
Org.DataBind();

position.DataSource=dsClub;
position.DataValueField=dsClub.Tables["Position"].Columns[1].ToString();
position.DataTextField=dsClub.Tables["Position"].Columns[1].ToString();
position.DataBind();

AccessGroup.DataSource=dsClub;
AccessGroup.DataTextField=dsClub.Tables["Access"].Columns[0].ToString();
AccessGroup.DataValueField=dsClub.Tables["Access"].Columns[1].ToString();
AccessGroup.DataBind();
}
It is probably very wrong to assume I can one dataset with three different
tables to three different DropDownList controls but if it is possible can
someone tell me how?

I am Sam
 
K

Karl Seguin

Sam:
Use the DataMember after setting the source:
Org.DataSource=dsClub;
Org.DataMember = "Club"
....

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top