DropDownList

Discussion in 'ASP .Net Datagrid Control' started by Seelan, May 19, 2005.

  1. Seelan

    Seelan Guest

    Hello folks,
    I have a database table with CategoryID, Name and Description. I
    made 2 DropDown Lists one for Displaying Name and the other for
    Description. I want to add a web control, lets say a simple Datagrid
    that would display the CategoryID depending on the values selected
    from the 2 drop down lists. Can some one help me with this please? C#
    web forms would be very helpful.

    sqlDataAdapter1.Fill(dsCategories11);
    DataGrid1.DataBind();
    DropDownList1.DataBind();
    DropDownList2.DataBind(); //upto this
    point data is binded to the ddlist and everything is fine...

    sqlDataAdapter1.SelectCommand.CommandText="SELECT CategoryID FROM
    Categories WHERE CategoryName="+DropDownList1.SelectedItem.ToString();
    sqlDataAdapter1.Fill(dsCategories121);
    Datagrid2.DataBind();

    //after this I get an error saying "Invalid Coloumn name 'Beverage'
    which is the item selected in the drop down list 1.

    Please help...
    Thanks
    Seelan
     
    Seelan, May 19, 2005
    #1
    1. Advertising

  2. Seelan

    EJD Guest

    Hi,

    I don't know what you're using for your database software, but just as
    a suggestion, can you reproduce the full query string along with the
    parameter 'Beverage' from the web page and run it in the DB software
    itself?

    I have a similar setup to yours but it's only using one DDL, and if I
    change part of the query by adding a letter to one of the parameters,
    say in your case making "CategoryName" into "CategoryName1," it would
    give me the same error but instead of it saying "invalid column name
    'beverage'" it would say invalid column name 'CategoryName1'.

    You may want to check what your DDL1.DataMember equals as well...
    I suppose it could also be that there is some kind of disconnect
    between your query and your dsCategor­ies121...

    HTH.
     
    EJD, May 22, 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. mr2_93
    Replies:
    1
    Views:
    3,629
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,247
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,885
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,319
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    12,081
    shauns1
    Nov 1, 2006
Loading...

Share This Page