Row Count = DataTable.Rows.Count (dt.Rows.Count in your case)
Value = dt.Rows[0][0] will give you the value of the 1st column in the 1st row. You
can also access columns by name, for instance dt.Rows[0]["id"]
Greg Ewing [MVP]
www.citidc.com
Original Message:
>From: Arindam <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: [AspNetAnyQuestionIsOk] HOw do i get the values of a column in my data
>Table
>Date: Tue, 25 May 2004 15:11:22 +0100 (BST)
>
>Hello All I have 2 question to ask
>1. HOw do i get the number of row count ?
>2. HOw do i get the values of a column in my data Table
>
>
>
> ICollection MakeGridSet()
> {
>
> myConnection mycon=new myConnection();
> mycon.openConnection();
>
> string strsql;
> strsql="Select oName ,oEmail,oCountry from regDtls";
> string strsql2;
> strsql2="Select oEmail,oPassword,nTrydate from regUserlogin";
>
> file://SqlCommand sqlCom = new SqlCommand(strsql, mycon.mysqlconn);
> SqlDataAdapter sqlAdap=new SqlDataAdapter(strsql, mycon.mysqlconn);
> SqlDataAdapter sqlAdap1=new SqlDataAdapter(strsql2, mycon.mysqlconn);
>
> DataSet ds = new DataSet();
> sqlAdap.Fill(ds,"myTable");
> sqlAdap1.Fill(ds,"myTable1");
> file://************************************
> DataTable dt = new DataTable();
> DataRow dr;
>
> dt.Columns.Add(new DataColumn("Name", typeof(string)));
> dt.Columns.Add(new DataColumn("Email", typeof(string)));
> dt.Columns.Add(new DataColumn("Country", typeof(string)));
>
> // here i am trying to get the number of rows ;
> // but "dt.Rows.Count" returns 0
>
> for (int i = 0; i < 5 ; i++)
> {
> dr = dt.NewRow();
>
>dr[0]=ds.Tables["myTable"].Columns["oName"];//here i need the value of the column.
>dr[1]=ds.Tables["myTable"].Columns["oEmail"];//but it returns name which i dont want
>dr[2]=ds.Tables["myTable"].Columns["oCountry"];
>
> dt.Rows.Add(dr);
> }
> mycon.closeconnection();
> DataView dv = new DataView(dt);
> return dv;
>
> }
>
>
>
>
> private void Search_Click(object sender, System.EventArgs e)
> {
>
>file://ds.Relations.Add("CompanyContacts",ds.Tables["myTable"].Columns["oEmail"],ds.Tables["myTable1"].Columns["oEmail"]);
>
>
>
> file://DataGrid1.DataSource = ds.Tables["myTable"].DefaultView() ;
> DataGrid1.DataSource =MakeGridSet() ;
> DataGrid1.DataBind();
>
> file://Counting number of records
> TextBox2.Text=DataGrid1.Items.Count.ToString() ;
> }
>
>
>
>Regards
>
>Arindam
>
>
>
>Yahoo! India Matrimony: Find your partner online.
>
>[Non-text portions of this message have been removed]
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/