473,320 Members | 1,846 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,320 software developers and data experts.

How to display values in Dropdowncombo from a dataset or dataview object?

I've given code like this ,
SqlConnection cnn = new qlConnection("initial talog=vin;uid=sa;pwd=;");
cnn.Open();
string strsql="select * from tblQualification";
SqlCommand cmd=new SqlCommand(strsql,cnn);
/// SqlDataReader rsreader=cmd.ExecuteReader();
SqlDataAdapter dadapt=new SqlDataAdapter();
dadapt.SelectCommand=cmd;
DataSet ds=new DataSet();
dadapt.Fill(ds,"tblA");
DataView dview=new DataView(ds.Tables["tblA"]);
DropDownList1.DataSource=dview;
DropDownList1.DataBind();

but the value displayed is "SYSTEM.DATAROW.DATAVIEW".

It will be helpful if some one could point me to some code sample for the
same

thank you in advance


Nov 15 '05 #1
2 2483


Try adding at the end
DropDownList1.DisplayMember=ds.Tables["tblAdd"].Columns[0].ColumnName;
DropDownList1.DisplayMember=ds.Tables["tblAdd"].Columns[1].ColumnName;

or choose yourself what should the user see and what should be the value of
the combo

Hope this helps

Dan Cimpoiesu
"Vinitha" <vi*******@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP09.phx.gbl...
I've given code like this ,
SqlConnection cnn = new qlConnection("initial talog=vin;uid=sa;pwd=;");
cnn.Open();
string strsql="select * from tblQualification";
SqlCommand cmd=new SqlCommand(strsql,cnn);
/// SqlDataReader rsreader=cmd.ExecuteReader();
SqlDataAdapter dadapt=new SqlDataAdapter();
dadapt.SelectCommand=cmd;
DataSet ds=new DataSet();
dadapt.Fill(ds,"tblA");
DataView dview=new DataView(ds.Tables["tblA"]);
DropDownList1.DataSource=dview;
DropDownList1.DataBind();

but the value displayed is "SYSTEM.DATAROW.DATAVIEW".

It will be helpful if some one could point me to some code sample for the
same

thank you in advance

Nov 15 '05 #2
Hi Vinitha,

Just add the following two lines before you do databind

for the drop-down list box.

DropDownList1.DataTextField="au_lname";
DropDownList1.DataValueField="au_id";

Hope this helps.

Cheers!!!

Nitin.
-----Original Message-----
I've given code like this ,
SqlConnection cnn = new qlConnection("initial talog=vin;uid=sa;pwd=;"); cnn.Open();
string strsql="select * from tblQualification";
SqlCommand cmd=new SqlCommand(strsql,cnn);
/// SqlDataReader rsreader=cmd.ExecuteReader();
SqlDataAdapter dadapt=new SqlDataAdapter();
dadapt.SelectCommand=cmd;
DataSet ds=new DataSet();
dadapt.Fill(ds,"tblA");
DataView dview=new DataView(ds.Tables["tblA"]);
DropDownList1.DataSource=dview;
DropDownList1.DataBind();

but the value displayed is "SYSTEM.DATAROW.DATAVIEW".

It will be helpful if some one could point me to some code sample for thesame

thank you in advance


.

Nov 15 '05 #3

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

Similar topics

3
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if...
1
by: Arthur Dzhelali | last post by:
I according to MSDN dataview and dataset are thread safe for read operations, but we run into this scenario. I just would like to see some comments on it. Aplication written in VB.NET it is an...
4
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't...
3
by: olle | last post by:
Hi everyone. Beging a newbee to asp.net and used to work with traditional asp I have one problem working with a datalist. 1/ I make a dataset as as session variable like session("employees") 2/...
5
by: Mountain Bikn' Guy | last post by:
How would I do this? public sealed class UtilityClass { public static MyObject Object1;//see note below about importance of static object names in this class public static MyObject Object2;...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
2
by: Jason Huang | last post by:
Hi, In the ASP.Net, what's the difference between DataSet and DataView? I what situation will I choose to use the DataSet or DataView? Thanks for help. Jason
3
by: Björn | last post by:
Hi List I´m generating a DataSet using a simple sql select statement. Now my DataSet has several rows with columns(ID,NAME,CAPTION) Now I want to sort the DataSet for column Caption. I can´t...
2
by: Sandy | last post by:
Hello - I have the following stored procedure and code. I want to put the results in two textboxes. I get to the part where I create the dataset and then I don't know what to do. I tried...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
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...
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

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.