I want's to change the layout of my table at run time on the basis of some of my Setting File[I don't want's to use webpart orwebzones]
Suppose I have three Tables with number of rows.[In reality Each row will contain some controls]
On Page_Preinit I want's to set the rows of one table to another also want's to change order of the rows.
How Can I do that ?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <table width="100%"> <tr> <td width="33%" valign="top"> <table width="100%" runat="server" id="Table1"> <tr> <td runat="server" id="Td1"> A1 </td> </tr> <tr> <td runat="server" id="Td2"> A2 </td> </tr> <tr> <td runat="server" id="Td3"> A3 </td> </tr> </table> </td> <td width="34%" valign="top"> <table width="100%" runat="server" id="Table2"> <tr> <td runat="server" id="Td4"> B1 </td> </tr> <tr> <td runat="server" id="Td5"> B2 </td> </tr> </table> </td> <td width="33%" valign="top"> <table width="100%" runat="server" id="Table3"> <tr> <td runat="server" id="Td7"> C1 </td> </tr> <tr> <td runat="server" id="Td8"> C2 </td> </tr> <tr> <td runat="server" id="Td9"> C3 </td> </tr> <tr> <td runat="server" id="Td10"> C3 </td> </tr> </table> </td> </tr> </table> </div> </form> </body> </html>
Kamran Shahid
Sr. Software Engineer
(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
Netprosys Inc.
www.netprosys.com
Remember to click "Mark as Answer" on the post that helps U
![]() |
0 |
![]() |
There are a couple of options to give you complete control over the rendering of tables...
1. Based on your conditions you can generate the rows and the columns like as shown in the example below taken from http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.table.rows.aspx
// Generate rows and cells.
int numrows = 3;
int numcells = 2;
for (int j = 0; j < numrows; j++)
{
TableRow r = new TableRow();
for (int i = 0; i < numcells; i++) {
TableCell c = new TableCell();
c.Controls.Add(new LiteralControl("row "
+ j.ToString() + ", cell " + i.ToString()));
r.Cells.Add(c);
}
Table1.Rows.Add(r);
}2. You could use a string literal in your c# class to actually build your tables like "<table><tr><td><td><tr>..."
![]() |
0 |
![]() |
That is not what i want's.I know how to generate the Tables and rows.
I have some predeifned tables with some rows.
I want's to change one row from one table to another row from another table
Kamran Shahid
Sr. Software Engineer
(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
Netprosys Inc.
www.netprosys.com
Remember to click "Mark as Answer" on the post that helps U
![]() |
0 |
![]() |
If you have predefined tables and you know what is inside the tables before, then you can just add all the rows that you need into the table, hide the ones that you want and display the others...since all your rows are accessible in your code you could just go Table2Td1.Visible=false....
<td width="33%" valign="top">
<table width="100%" runat="server" id="Table1">
<tr>
<td runat="server" id="Td1">
A1
</td>
</tr>
<tr>
<td runat="server" id="Td2">
A2
</td>
</tr>
<tr>
<td runat="server" id="Td3">
A3
</td>
</tr>
</table>
</td>
<td width="34%" valign="top">
<table width="100%" runat="server" id="Table2">
<tr>
<td runat="server" id="Td4">
B1
</td>
</tr>
<tr>
<td runat="server" id="Td5">
B2
</td>
</tr><td runat="server" id="Table2Td1" visible="false"> //so now you have a row from Table 1 hidden, you can hide it or display it
A1
</td>
</tr>
<tr>
<td runat="server" id="Table2Td2" visible="false">
A2
</td>
</tr>
</table>
</td>
![]() |
0 |
![]() |
Read up on the DOM methods for removeChild, removeNode, and appendChild. These are what you would use to remove a row from one table and add it to another table, respectively. Internet Explorer has a table API (with methods like insertRow and deleteRow) that you can read about at http://msdn2.microsoft.com/en-us/library/ms535901.aspx, but these attributes don't necessarily translate to other browsers like Firefox and Safari.
Regards,
Peter Brunone
MS MVP, ASP.NET
Founder, EasyListBox.com
Do the impossible, and go home early.
![]() |
0 |
![]() |
Then what Can I do to achieve these Functionality.
I basically have a data entry form with number of section.
A user with site administrator role can set the order of the entry.
I will save it in an xml file then on the DataEntry pages render my control to certain section on the basis of it.
Any Idea How Can I achieve that ?
Kamran Shahid
Sr. Software Engineer
(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
Netprosys Inc.
www.netprosys.com
Remember to click "Mark as Answer" on the post that helps U
![]() |
0 |
![]() |