Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 26, 2009 05:42 AM by raghav_khunger
Member
13 Points
49 Posts
Jan 26, 2009 03:37 AM|LINK
I have the Table Name, the Column Name and the id which can identify the row from the table, how can I locate which cell of the table?
Thank you.
All-Star
78956 Points
13402 Posts
MVP
Jan 26, 2009 04:38 AM|LINK
Suppose your datatable is dt
C#
DataRow[] dr = dt.Select("Name = '" + MAK + "'"); //This will select all rows where the Name Column has value MAK
for(int i=0i<dr.length;i++)
{
string phone = dr[i]["Phone"].ToString(); //To get the value of the phone column
}
VB
Dim dr as DataRow() = dt.Select("Name = '" + MAK + "'") //This will select all rows where the Name Column has value MAK
for i as integer = 0 to dr.length-1
Dim phone as String = dr[i]["Phone"].ToString() //To get the value of the phone column
32835 Points
5563 Posts
Jan 26, 2009 05:42 AM|LINK
Hi,hanxiao
Suppose U have A Datatable dt and I am supposing that it has rows with two columns
U can Fetch tht logic
U can Try this example
col1=dt.Rows[i][
I have assumed that ur two columns are string and u can convert that to proper datatype
depending upon ur columns datatype.
hanxiao
Member
13 Points
49 Posts
How to access a cell in a DataTable?
Jan 26, 2009 03:37 AM|LINK
I have the Table Name, the Column Name and the id which can identify the row from the table, how can I locate which cell of the table?
Thank you.
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: How to access a cell in a DataTable?
Jan 26, 2009 04:38 AM|LINK
Suppose your datatable is dt
C#
DataRow[] dr = dt.Select("Name = '" + MAK + "'"); //This will select all rows where the Name Column has value MAK
for(int i=0i<dr.length;i++)
{
string phone = dr[i]["Phone"].ToString(); //To get the value of the phone column
}
VB
Dim dr as DataRow() = dt.Select("Name = '" + MAK + "'") //This will select all rows where the Name Column has value MAK
for i as integer = 0 to dr.length-1
{
Dim phone as String = dr[i]["Phone"].ToString() //To get the value of the phone column
}
Contact me
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: How to access a cell in a DataTable?
Jan 26, 2009 05:42 AM|LINK
Hi,hanxiao
Suppose U have A Datatable dt and I am supposing that it has rows with two columns
U can Fetch tht logic
U can Try this example
string col1, col2;if (dt.Rows.Count > 0){
for (int i = 0; i < dt.Rows.Count; i++){
col1=dt.Rows[i][
"col1Name"].ToString() ; col2=dt.Rows[i]["col2Name"].ToString();}
}
I have assumed that ur two columns are string and u can convert that to proper datatype
depending upon ur columns datatype.