Multiple DataBinds off one DataSet

Discussion in 'ASP .Net' started by =?Utf-8?B?SSBhbSBTYW0=?=, Mar 16, 2005.

  1. 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
    =?Utf-8?B?SSBhbSBTYW0=?=, Mar 16, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?SSBhbSBTYW0=?=

    Karl Seguin Guest

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

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "I am Sam" <> wrote in message
    news:...
    > 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
    Karl Seguin, Mar 16, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Johnson

    2 databinds in 1 parameter

    Mike Johnson, Apr 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,034
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Apr 2, 2004
  2. Steve
    Replies:
    0
    Views:
    451
    Steve
    Jan 31, 2006
  3. loveNUNO
    Replies:
    2
    Views:
    907
    loveNUNO
    Nov 20, 2003
  4. =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz

    GridView auto databinds for any Postback?

    =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz, May 14, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    585
    =?Utf-8?B?YnVybG8=?=
    May 15, 2007
  5. RRB
    Replies:
    1
    Views:
    155
Loading...

Share This Page