ddl binding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brettokumar
    New Member
    • Jul 2008
    • 31

    ddl binding

    hi
    i am binding values from database to ddl through sqldatareader
    records are binding in my dripdownlist but my first record is dosen't bind
    i.e if i have 4 records in my table. ddl is binding only three records from 2 to 4 only dosen't bind 1st record.
    shall i know what is the problem

    please help me...
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Can you print your code please where you load your data and bind it to the DropDownList.

    Are you doing anything like
    Code:
    If Not DBReader.Read Then
    before binding to the DropDownList? Remember that .Read will move the reader on to the nex record.

    Dr B

    Comment

    • brettokumar
      New Member
      • Jul 2008
      • 31

      #3
      hi
      this is my code

      Code:
      string strpos = "select * from adposition";
                  sdr = daClass.getdr(strpos);
                 
                  if (sdr.Read())
                  {
                      ddl_adsposition1.DataSource = sdr;
                      ddl_adsposition1.DataTextField = "ads_posname";
                      ddl_adsposition1.DataValueField = "ads_posid";
                      ddl_adsposition1.DataBind();
                  }
                  sdr.Close();
      Last edited by DrBunchman; Aug 10 '08, 10:17 AM. Reason: Added [Code] Tags - Please use the '#' button

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Then that's why - remove the
        Code:
        if (sdr.Read())
        statement and it will work.
        Dr B

        Comment

        • brettokumar
          New Member
          • Jul 2008
          • 31

          #5
          thanks man thank u very much

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            No problem! Glad to help.

            Dr B

            PS Please remember to wrap your code in CODE tags using the # button - it makes your posts much easier to read. Check the Posting Guidelines for details.

            Comment

            Working...