Wednesday, August 18, 2010

I have a table (employee) in sqlserver with these fields(Id,Name,Family,Birthdat鈥?,?

Now I want to show the information with asp.net , but I shoulnt use Gridview to show the info , I have to use Tbale instead , but i dont know how to do that , I just know how to show it with grid view using this code:


SqlConnection con = new SqlConnection(ConfigurationManager.Conne鈥?br>

SqlCommand cmd = new SqlCommand(';select * from employee';, con);


cmd.Connection.Open();


SqlDataReader dr = cmd.ExecuteReader();


GridView1.DataSource = dr;


GridView1.DataBind();


cmd.Connection.Close();





can you tell me plz how can i do this with table ?I have a table (employee) in sqlserver with these fields(Id,Name,Family,Birthdat鈥?,?
Here's something to get you started. Make sure you are implementing the System.Data interface as well:





SqlConnection con = new SqlConnection(ConfigurationManager.Conne鈥?br>

SqlCommand cmd = new SqlCommand(';select * from employee';, con);


cmd.Connection.Open();


SqlDataAdapter da = new SqlDataAdapter(cmd);


DataSet ds = new DataSet();


da.Fill(ds);


foreach (DataRow row in ds.Tables[0].Rows)


{


TableRow tRow = new TableRow();


TableCell cellOne = new TableCell();


// Add as many table cells as you need...





cellOne.Text = row[';ColumnName';].ToString();


// Update the cells' text properties. You can also update the


// properties of the row based on DB criteria.





// Add the cell to the row


tRow.Cells.Add(cellOne);





// Add the row to the table


Table.Rows.Add(tRow);





}

No comments:

Post a Comment