0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by croker10
0

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.

Edited by croker10: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.