hello everybody; i have a aspx file in which i have made a table with 1 row; now i want to get the data of the user from database who have logined; i have written correct the sql query and it retriving the data, but i dont know how to add another row at runtime and the set values in it .... m new with asp.net kindly help thnx

Hi 080346,
Thats an interesting name you have.

This is assuming you are using an asp:Table control ie:

<asp:Table ID="MyTable" runat="server">
   <asp:TableHeaderRow>
        <asp:TableCell>Header 1</asp:TableCell>
        <asp:TableCell>Header 2</asp:TableCell>
   </asp:TableHeaderRow>
</asp:Table>

Then, in your code, try this:

TableRow tr = new TableRow();
TableCell tc1 = new TableCell();
TableCell tc2 = new TableCell();

tc1.Text = "This is cell 1!";
tc2.Text = "This is cell 2!";

tr.Cells.Add(tc1);
tr.Cells.Add(tc2);

MyTable1.Rows.Add(tr);

You can also add controls and other such features to a cell as you may need, such as buttons. Keep in mind that the data is easy to write to a table, but much more difficult to retrieve, so if you need a lot of interaction with the data in the table, it would be more useful to use a gridview or something of that nature.

Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.