Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we assign a particular dataset column value to a variable

Tags:

c#

asp.net

I have a data set dsProcesses which returns some rows & columns.Now i need to store into a string all the data present in one particular column[Process-ID] of this data set.Can any one of u please suggest in a detailed way.

like image 208
Ravi Kiran Ayinampudi Avatar asked Feb 10 '14 09:02

Ravi Kiran Ayinampudi


2 Answers

Yes you can

String str = DataSet.Tables[0].Rows[RowIndex]["ColumnNameOrIndex"].ToString();
String str = DataSet.Tables["TableName"].Rows[0]["ColumnName"].ToString();

Take a look at Here

like image 179
Vignesh Kumar A Avatar answered Sep 30 '22 04:09

Vignesh Kumar A


This code will create comma delimited string with the data from that column

        for (int i = 0; i < dsProcesses.Tables[0].Rows.Count; i++)
        {
            strprocessid = strprocessid + dsProcesses.Tables[0].Rows[i]["ProcessID"].ToString() + ",";
         }
        strprocessid = strprocessid.TrimEnd(',');
like image 22
Ravi Kiran Ayinampudi Avatar answered Sep 30 '22 03:09

Ravi Kiran Ayinampudi