Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DropDownList

Reply
Thread Tools

DropDownList

 
 
Seelan
Guest
Posts: n/a
 
      05-19-2005
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
 
Reply With Quote
 
 
 
 
EJD
Guest
Posts: n/a
 
      05-22-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList inside GridView: How to set SelectedIndex for the DropDownList? keithb ASP .Net 1 11-01-2006 05:24 AM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments