C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




how to get value of cell of datatable in c#


Posted Date: 28 May 2008      Total Responses: 5

Posted By: Lalit...wait for ANS       Member Level: Gold     Points: 1


how to get value of cell of datatable in c#:
I need to get the value from datatable from eachrow in single row...how it is?




Responses

Author: Ashok Kandasamy    28 May 2008Member Level: DiamondRating:     Points: 2
hi,
Try this,

DataTable dt = new DataTable();
string rowValue = dt.Rows[0].ToString();
string coloumnValue = dt.Columns[0].ToString();



Author: Sujit Kumar    28 May 2008Member Level: GoldRating:     Points: 2
datatable.Rows[0][0]

//Rows[0][0], first[0] means rows and second [0] means column


Author: kavithiagu    28 May 2008Member Level: SilverRating:     Points: 2
try it

if (ds1.Tables.Count > 0)
{
for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
{
DataRow odr = ds1.Tables[0].Rows[j];

dataGridView1.Rows.Add();
dataGridView1.Rows[j].Cells[1].Value = odr["columnname"].ToString();
dataGridView1.Rows[j].Cells[2].Value = odr["columnname"].ToString();
dataGridView1.Rows[j].Cells[4].Value = odr["columnname"].ToString();
dataGridView1.Rows[j].Cells[2].ReadOnly = true;
dataGridView1.Rows[j].Cells[4].ReadOnly = true;

}


Author: Siva Prasad    28 May 2008Member Level: GoldRating:     Points: 2
Hello Lalit,

string cellValue = dataTable.Rows[0][1].ToString();

Siva Prasad


Author: Parashu(Swathimutyam)    28 May 2008Member Level: GoldRating:     Points: 2
for (int i = 0; i < ds.Tables["reg_table"].Rows.Count; i++)
{
for (int j = 0; j < ds.Tables["reg_table"].Columns.Count; j++)
{
items.Add(ds.Tables["reg_table"].Rows[i][j].ToString());
}
}

the above code will retrive a first row and all the columns,
based on this idea please implement your code

Regards,
Parshu(Swathimutyam)


Post Reply
You must Sign In to post a response.
Next : cookies problem
Previous : Paging in Datagrid
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

fax server

Contact Us    Privacy Policy    Terms Of Use