How can I get the value of one single column from a DataSet/DataView?

I have a DataSet or DataView that contains a bunch of info.

I can filter down to one row using .RowFilter on the DataView.
I want to simply populate a label with the string value of column "A" for example.
This should be easy, but I am struggling with it.
Any suggestions?
--[_]-[_]--

AGENT_SMITH
0
agent_smith
3/3/2004 1:52:27 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

5 Replies
182 Views

Similar Articles

[PageSpeed] 3

Well a dataview is going to give a Row of data....

It's up to you to just bind or fetch the single column that you are looking for....
Here is an example of some code that I use to fetch from the ASP.Cache object a readonly dataview....
and use it as the datasource for my custom control.

private void LoadDropDown(CustomDropDown dropDown,int index){
if(myDataView == null)
myDataView = DictionaryServices.GetCodesAndDescriptions(64); // fetches a view from ASP.NET Cache Object and does some filter and sorting to return a dataview.

dropDown.DataSource = myDataView;
dropDown.DataTextColumns = "CODE,CODE_DESCR"; // custom control ignore
dropDown.DataValueField = "CODE";
dropDown.Text = data.myDataList.Count > index?data.myDataList[index].Code:string.Empty;
dropDown.DataBind();
}

Here I'm using only the said columns that I desire

// note codeDescription is a dataview
DropDownList dropDown = new DropDownList();
dropDown.DataSource = codeDescriptionView;
dropDown.DataTextField = codeDescriptionView[0]["CODE_DESC"];
dropDown.DataValueField = codeDescriptionView[0]["CODE"];
dropDown.DataBind();

pretty straight forward...:)
XMLViking





"Knowledge is Power"


- Francis Bacon
0
xmlviking
3/3/2004 10:04:52 PM
In both cases you are binding a collection to a control that accepts a collection as a datasource.

I want ONE row/column assigned to a label.
i.e.,
lblWhatever.Text = dv......ToString();
Thanks. I will look closer at it.
--[_]-[_]--

AGENT_SMITH
0
agent_smith
3/3/2004 11:13:47 PM
Just look at this line:

string var = codeDescriptionView[0]["CODE_DESC"];

Where codeDescriptionView is the view
codeDescriptionView[x] is the row
codeDescriptionView[0][x or ""] is the column index or string....
tip...index is faster
ok?
XMLViking





"Knowledge is Power"


- Francis Bacon
0
xmlviking
3/4/2004 12:29:39 AM
Awesome.

Simple.
Thanks.
--[_]-[_]--

AGENT_SMITH
0
agent_smith
3/4/2004 12:34:00 PM
no problem :)

Have a good one :)
Eric Cotter
XMLViking





"Knowledge is Power"


- Francis Bacon
0
xmlviking
3/4/2004 5:02:49 PM
Reply:

Similar Artilces:

How to get a single value(column) from a dataset
HI guysPlease help me, i have a page with a datagrid(gets the values from a dataset). And i have another  dataset from which i want to only display the value of one column from it.How do i do that in the code behind? Thank you :chomp: Thank you,i got itdatatable = dataset.Tables(0)datarow = datatable.Rows(0)lblLabel1.Text = CStr(datarow("column you want")) 'this is if you want it on a label...

How do I extract a single value from a single column in a single row in a dataset?
First of all, thank you to everyone who takes time to answer basic questions in this forum. Your patience is deeply appreciated. For the past day, I've been trying to figure out how to access a single value in a row of a data set. The data layer tutorials by Scott Mitchell are helpful, but I still can't figure out how to extract a single value without looping through the data set. By passing a Client_ID to an instance of my data adapter, I am able to return a unique row that contains a column labeled Family_ID. However, I can't figure out how to access the value of that column on...

How can I get other column value of DataSource in ItemDataBound event?
Hi all In ItemDataBound event, How can I get other column value of DataSource? for example ,I have 3 column,customer_id,customer_name,customer_tel customer_id,customer_name has display on DataGrid. Now I want to get customer_tel in ItemDatabound event. How do I? Thanks a lot. Clare There is a DataItem property of the e.Item that ruturns items datasource. All you need to do is to cast it to an appropriate type. If you binding your grid to DataTable or DataView, it is DataRowView Dim dtr as DataRowView = ctype(e.Item.DataItem,DataRowView) Bug [MCSD]...

How can one get a column name from a Linq-To-Entites object
All -- Please help. How can one get a column name from a Linq-To-Entites object? For example, see this code...  //With ADO, I can get a column name something like this... DataTable myTable = new DataTable();myTable.Columns.Add(new DataColumn("myColName", typeof(string));string myValue = myTable.Columns[0].ColumnName;//With Linq, I want to get (but cannot get) a column name something like this...  public static TestProject.Data.Entities.TestEntity GetEntity(Guid targetPkID){ Data.Components.Ssbi myEntity = null;  using (Data.Entities.TestDataCon...

How get one value from one column from sqldatasource?
Hi, a few days i am trying to get one value from one column from database and put in one local variable (INT)........   i trying this:protected void SqlDataSource1_Load(object sender, EventArgs e)protected void SqlDataSource1_Load(object sender, EventArgs e) {  Int32 status;  SqlDataSource1.SelectCommand= "SELECT status FROM users WHERE Username='" + Membership.GetUser() + "'";status = SqlDataSource1.Select(DataSourceSelectArguments.Empty);   } "status" is the variable in question....   anyone can help me?  tan...

How can I get the values from array and pass them one by one to the datagrid?
  Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; ...

How to get value of field in one DataView into an Select statement for another DataView?
I have a DataView, called DataView1, that is showing the data from a table called INFO.  A DetailsView is attached to this DataView.When I click the Select link on a record for DataView1, I want the value of a certain field of DataView one to be put into the Select query of DataView2.  The reason being is this.DataView1 contains the data for my INFO table.DataView2 contains the data for my FILES table.INFO can have many FILES.Files can only have one INFO.  So when I click the Select link on a record on my DataView1(INFO table), I want only the files associated with t...

Getting a Single Value From a DataSet
This seems like such a silly question, but I haven't found the answer yet. How do I get a single value from a DataSet? Like, if the DataSet has a table "TableX" which has a field/column "ValueX", then how do I get "ValueX" for a given row? I've only been using DataSets to bind whole columns and stuff thus far. If you are returning a 1x1 result (e.g. SELECT Count(*) FROM Table1), then you should look at using the .ExecuteScalar() method instead of using a DataSet. You can find it on all of the providers (SqlCommand, OleDbCommand). Incidentally, have you ...

Getting value of a single column
Hello Everyone, I am new to this group and Powerbuilder. Therefore, any help would be greatly appreciated. Here is my situation: I have a datawindow (dw_trafficmarkets) and I would like to get the value of the "Mktname" column for all the rows in this datawindow. Can anyone help me? dw_trafficmarkets ************* * Chicago * * New York * * Atlanta * * Etc. * ************* I need to get all the values from the above data window and then use them to select a list of products from a table where the markets equal the markets con...

Choosing between two column values to return as single column value
I'm working on a social network where I store my friend GUIDs in a table with the following structure:user1_guid       user2_guidI am trying to write a query to return a single list of all a users' friends in a single column.  Depending on who initiates the friendship, a users' guid value can be in either of the two columns.  Here is the crazy sql I have come up with to give what I want, but I'm sure there's a better way...  Any ideas?SELECT DISTINCT UserIdFROM espace_ProfilePropertyWHERE (UserId IN ...

How can i get the default-value of a column
I' m using this statement with VB 6.0: select column_name, table_name, "default" from syscolumn, systable join syscolumn on systable.table_id = syscolumn.table_id where table_name='TRegieBuchungen' => it works fine with ISQL. But when i refer to the result-set of VB, i always get an Error "No update tables are specified". Any ideas? thanks! Christian c.pauzenberger@telecom.at ...

How can I get data value from datasource
I Have extracted data from an access database created a datagrid which works great. In the data grid I am only using part of the columns extracted from the data base. The dataTarps_Commands sub is executed when a link button is clicked in the datagrid. I am able to retive item data that is displayed using bound columns in the data grid but I have not been able get cell information for columns not displayed or displayed using template columns. Is there a way to get information from the data source in a function. Ideally I would like to address these cells using the header name and curren...

How can i get the default-value of a column?
I' m using this statement with VB 6.0: select column_name, table_name, "default" from syscolumn, systable join syscolumn on systable.table_id = syscolumn.table_id where table_name='TRegieBuchungen' => it works fine with ISQL. But when i refer to the result-set of VB, i always get an Error "No update tables are specified". Any ideas? thanks! >select column_name, table_name, "default" from syscolumn, systable join >syscolumn on systable.table_id = syscolumn.table_id where >table_name='TRegieBuchungen' >...

How can I get the value of a column in a datagrid?
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much in advance This is the code that loops through all rows. find the textboxes controls Private Sub btnguardarplandesarrollo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnguardarplandesarrollo.Click Page.Validate() If Page.IsValid Then Dim cont As Int32 = 0 Dim di As DataGridItem For Each di In dgplandesarrollo.Items Dim responsabili...

Web resources about - How can I get the value of one single column from a DataSet/DataView? - asp.net.object-datasource

Resources last updated: 11/21/2015 5:24:09 AM