473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

DropDownList and DataSet. Where is my error?

Hi People, I want populate one DropDownList with a DataSet.
I've got one problem when I pass the data and text value. My code
(propabily wrong)
pass always the first value of my droplist.

DataSet dst = new DataSet();
dst = myobject.GetDataSet();
droplist.DataSource = dst.Tables[0];
droplist.DataTextField =
dst.Tables[0].Columns["TextValueColumn"].ToString();
droplist.DataValueField =
dst.Tables[0].Columns["DataValueColumn"].ToString();
droplist.DataBind();

***************************
this.Label1.Text = droplist.SelectedItem.Text;
this.Label2.Text = droplist.SelectedItem.Value;

Can you help me?

(sorry for my english, but I'm italian....!)

Jul 20 '07 #1
2 1181
On 20 Lug, 15:20, Emanuele <emanuele.vec...@mecdata.itwrote:
Hi People, I want populate one DropDownList with a DataSet.
I've got one problem when I pass the data and text value. My code
(propabily wrong)
pass always the first value of my droplist.

DataSet dst = new DataSet();

dst = myobject.GetDataSet();

droplist.DataSource = dst.Tables[0];
droplist.DataTextField =
dst.Tables[0].Columns["TextValueColumn"].ToString();
droplist.DataValueField =
dst.Tables[0].Columns["DataValueColumn"].ToString();
droplist.DataBind();

***************************
this.Label1.Text = droplist.SelectedItem.Text;
this.Label2.Text = droplist.SelectedItem.Value;

Can you help me?

(sorry for my english, but I'm italian....!)
Nobody can help me?

Jul 20 '07 #2
Don't worry - I wish I could speak Italian half as good as you speak English
are you having troubles setting the DataTextField/DataValueField, before
binding, or in the label part you had below it?

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com

"Emanuele" <em*************@mecdata.itwrote in message
news:11*********************@k79g2000hse.googlegro ups.com...
Hi People, I want populate one DropDownList with a DataSet.
I've got one problem when I pass the data and text value. My code
(propabily wrong)
pass always the first value of my droplist.

DataSet dst = new DataSet();
dst = myobject.GetDataSet();
droplist.DataSource = dst.Tables[0];
droplist.DataTextField =
dst.Tables[0].Columns["TextValueColumn"].ToString();
droplist.DataValueField =
dst.Tables[0].Columns["DataValueColumn"].ToString();
droplist.DataBind();

***************************
this.Label1.Text = droplist.SelectedItem.Text;
this.Label2.Text = droplist.SelectedItem.Value;

Can you help me?

(sorry for my english, but I'm italian....!)

Jul 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
1
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
0
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a...
4
by: Iain Kirk | last post by:
Being a bit of a novice any help or pointers would be appreciated. I am building a web page that populates a DropDowList from a table in SQL, for testing purposes i have a simple page that...
5
by: DC Gringo | last post by:
I've got a command button to submit a value from a dropdown list that should then filter a SELECT query. I'm simply appending a WHERE colx = <variableSelectedFromDropdownList>. How do I pass this...
3
by: Richard | last post by:
I've seen articles on GotDotNet and elsewhere on how to put a ddl in a datagrid, and have been able to implement this technique. For a new item, among the datagrid columns there is the one ddl for...
4
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak...
1
by: Eugene Anthony | last post by:
ModifyUserRegistration.aspx --------------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModifyUserRegistration.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.