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

get dataRow value from false column name

I have a DataRow (from DataTable) and i want to get data from a column
name that might not exist.
public static object getObject(DataTable dataTable, int index,
string columnName)
{
return dataTable.Rows[index][columnName];
}

if the column name does not exist - exception will be thrown.
Is there a fast way to check if the column exist (without iterating
over all the columns)?

Dec 4 '06 #1
1 2804
dataTable.Columns.Contains(columnName)

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"orenl" <or*****@yahoo.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
>I have a DataRow (from DataTable) and i want to get data from a column
name that might not exist.
public static object getObject(DataTable dataTable, int index,
string columnName)
{
return dataTable.Rows[index][columnName];
}

if the column name does not exist - exception will be thrown.
Is there a fast way to check if the column exist (without iterating
over all the columns)?

Dec 4 '06 #2

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

Similar topics

2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
2
by: Jean | last post by:
Hello Guys, I need to set a default value in the first column of my dataTable. I tried to do it: foreach (DataRow rowExp in tblExport.Rows) { rowExp.ItemArray.SetValue("false", 0); }
3
by: Shravan | last post by:
Hi, How can I bind DataRow array to ComboBox. I tried setting DataSource -> DataRow Array DisplayMember -> ColumnName But it was showing "System.Data.DataRow" for every item in the...
3
by: Chet | last post by:
I have a DataRow from a table in a data set. One of the columns has a name of "COMPANY_TICKET_ID" and I'm trying to get this column's value with the following: foreach( DataRow row in...
2
by: Ali M | last post by:
Hi, I am creating a TextBox dynamically at runtime within a Panel, and I want to bind its Text property to a DataColumn in a DataRow. What is the correct method for doing this... The following...
1
by: DotNetJunkies User | last post by:
I'm trying create a single page app that allows the user to enter text (Serial) via a form and submit and populate that value into a datagrid via a datatable. It works for ONE value but each time...
10
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
1
by: redgrL86 | last post by:
Hi, I am trying to create a table to display the values in the XML below. THe XSL provided works on the XML when there is only one <Step> but not three. Of the three steps in the XML below, two have...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.