Problem with Drop Down List

Discussion in 'ASP .Net' started by fazee.ent@gmail.com, Sep 23, 2006.

  1. Guest

    i am using a drop down list and have sucessfuly populated it proble is
    this i have set
    DataValueField = "cat_id" but value for dropdownlist appears a string
    "cat_id" instead of numer value of cat_id

    plz help me

    Faisal Iqbal Ch
    , Sep 23, 2006
    #1
    1. Advertising

  2. David Lozzi Guest

    Can you paste the actual code on here?

    Thanks

    David


    <> wrote in message
    news:...
    >i am using a drop down list and have sucessfuly populated it proble is
    > this i have set
    > DataValueField = "cat_id" but value for dropdownlist appears a string
    > "cat_id" instead of numer value of cat_id
    >
    > plz help me
    >
    > Faisal Iqbal Ch
    >
    David Lozzi, Sep 24, 2006
    #2
    1. Advertising

  3. Guest

    *****************
    Data binding Code
    *******************
    Const strSQL2 as String ="SELECT * FROM book_cat"
    Dim objCmd2 as New SqlCommand(strSQL2, objConn)

    objConn.Open() 'Open the connection

    cmbcat.DataSource =
    objCmd2.ExecuteReader(CommandBehavior. CloseConnection)
    cmbcat.DataBind()


    ****************
    Insertion Code
    ****************

    sql="INSERT INTO book_cat_sub
    (cat_name,cat_keywords,cat_head)VALUES('" & txtname.Text & "','" &
    txtkeywords.Text & "',"& cmbcat.DataValueField & ")"

    dbcomm=New OleDbCommand(sql,dbconn)
    dbread=dbcomm.ExecuteReader()

    dbread.Close()
    dbconn.Close()



    ****************
    Drop Down Lis code
    ****************

    <asp:DropDownList id="cmbcat" runat="server" DataTextField="cat_name"
    DataValueField="cat_id" ></asp:DropDownList>




    David Lozzi wrote:
    > Can you paste the actual code on here?
    >
    > Thanks
    >
    > David
    >
    >
    > <> wrote in message
    > news:...
    > >i am using a drop down list and have sucessfuly populated it proble is
    > > this i have set
    > > DataValueField = "cat_id" but value for dropdownlist appears a string
    > > "cat_id" instead of numer value of cat_id
    > >
    > > plz help me
    > >
    > > Faisal Iqbal Ch
    > >
    , Sep 24, 2006
    #3
  4. Guest

    *****************
    Data binding Code
    *******************
    Const strSQL2 as String ="SELECT * FROM book_cat"
    Dim objCmd2 as New SqlCommand(strSQL2, objConn)

    objConn.Open() 'Open the connection

    cmbcat.DataSource =
    objCmd2.ExecuteReader(CommandBehavior. CloseConnection)
    cmbcat.DataBind()


    ****************
    Insertion Code
    ****************

    sql="INSERT INTO book_cat_sub
    (cat_name,cat_keywords,cat_head)VALUES('" & txtname.Text & "','" &
    txtkeywords.Text & "',"& cmbcat.DataValueField & ")"

    dbcomm=New OleDbCommand(sql,dbconn)
    dbread=dbcomm.ExecuteReader()

    dbread.Close()
    dbconn.Close()



    ****************
    Drop Down Lis code
    ****************

    <asp:DropDownList id="cmbcat" runat="server" DataTextField="cat_name"
    DataValueField="cat_id" ></asp:DropDownList>




    David Lozzi wrote:
    > Can you paste the actual code on here?
    >
    > Thanks
    >
    > David
    >
    >
    > <> wrote in message
    > news:...
    > >i am using a drop down list and have sucessfuly populated it proble is
    > > this i have set
    > > DataValueField = "cat_id" but value for dropdownlist appears a string
    > > "cat_id" instead of numer value of cat_id
    > >
    > > plz help me
    > >
    > > Faisal Iqbal Ch
    > >
    , Sep 24, 2006
    #4
  5. David Lozzi Guest

    Can you look at the page source of the returned page and see if the value of
    the list items in then drop down box is also cat_id?


    <> wrote in message
    news:...
    > *****************
    > Data binding Code
    > *******************
    > Const strSQL2 as String ="SELECT * FROM book_cat"
    > Dim objCmd2 as New SqlCommand(strSQL2, objConn)
    >
    > objConn.Open() 'Open the connection
    >
    > cmbcat.DataSource =
    > objCmd2.ExecuteReader(CommandBehavior. CloseConnection)
    > cmbcat.DataBind()
    >
    >
    > ****************
    > Insertion Code
    > ****************
    >
    > sql="INSERT INTO book_cat_sub
    > (cat_name,cat_keywords,cat_head)VALUES('" & txtname.Text & "','" &
    > txtkeywords.Text & "',"& cmbcat.DataValueField & ")"
    >
    > dbcomm=New OleDbCommand(sql,dbconn)
    > dbread=dbcomm.ExecuteReader()
    >
    > dbread.Close()
    > dbconn.Close()
    >
    >
    >
    > ****************
    > Drop Down Lis code
    > ****************
    >
    > <asp:DropDownList id="cmbcat" runat="server" DataTextField="cat_name"
    > DataValueField="cat_id" ></asp:DropDownList>
    >
    >
    >
    >
    > David Lozzi wrote:
    >> Can you paste the actual code on here?
    >>
    >> Thanks
    >>
    >> David
    >>
    >>
    >> <> wrote in message
    >> news:...
    >> >i am using a drop down list and have sucessfuly populated it proble is
    >> > this i have set
    >> > DataValueField = "cat_id" but value for dropdownlist appears a string
    >> > "cat_id" instead of numer value of cat_id
    >> >
    >> > plz help me
    >> >
    >> > Faisal Iqbal Ch
    >> >

    >
    David Lozzi, Sep 26, 2006
    #5
    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. SirPoonga
    Replies:
    2
    Views:
    759
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,014
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    473
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    267
  5. Replies:
    3
    Views:
    285
Loading...

Share This Page