Connecting Tech Pros Worldwide Help | Site Map

Populate Table using Dataset

Junior
Guest
 
Posts: n/a
#1: Jan 30 '06
Hi All,

I haven't got a response for this question lately and i really need to
get this done ASAP.

I have a .aspx page that has table two column four rows on it.
1. How do i use codebehind C# to populate the HTML table?
2. How do i pull some figures from the second column and add them up in
the Total field.

here is a snipplet of the table:
<body MS_POSITIONING="GridLayout">
<form id=Form1 method=post runat="server">
<table>
<tr>
<td>Funds to Load</td>
<td><input style="WIDTH: 157px"
onchange=calculateTotal name=funds></td></tr>
<tr>
<td style="HEIGHT: 25px">Administrative Charge</td>
<td style="HEIGHT: 25px"><input id=admin
style="WIDTH: 157px; HEIGHT: 22px" disabled readOnly size=21
value=2%[color=blue]
></td></tr>[/color]
<tr>
<td>Minimum Adjustment</td>
<td><input id=minimum style="WIDTH: 157px" disabled readOnly
value=$1000></td></tr>
<tr>
<td style="HEIGHT: 27px">Total Funds Required</td>
<td style="HEIGHT: 27px"><input id=fundingTotal
style="WIDTH: 157px" disabled readOnly value=$1000[color=blue]
></td></tr>[/color]
<tr>
<td align=center colSpan=2><input type=submit value="Submit
Request"></td></tr></table>
<asp:Label id=Label1 style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 216px" runat="server" Width="168px" Height="24px">Funds
to Load</asp:Label>
<asp:Label id=Label2 style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 240px" runat="server" Width="176px"
Height="24px">Administrative Charge</asp:Label>
<asp:Label id=Label3 style="Z-INDEX: 103; LEFT: 16px; POSITION:
absolute; TOP: 264px" runat="server" Width="168px"
Height="24px">Minimum Adjustment</asp:Label>
<asp:Label id=Label4 style="Z-INDEX: 104; LEFT: 16px; POSITION:
absolute; TOP: 288px" runat="server" Width="168px" Height="16px">Total
Funds Required</asp:Label>
<asp:TextBox id=txtFundsToLoad style="Z-INDEX: 105; LEFT: 192px;
POSITION: absolute; TOP: 208px" runat="server" Width="161"
Height="24"></asp:TextBox>
<asp:TextBox id=txtAdmin style="Z-INDEX: 106; LEFT: 192px; POSITION:
absolute; TOP: 232px" runat="server" Width="161px" Height="24px"
ReadOnly="True" BackColor="#E0E0E0"></asp:TextBox>
<asp:TextBox id=txtMin style="Z-INDEX: 107; LEFT: 192px; POSITION:
absolute; TOP: 256px" runat="server" Width="161px"
Height="24px"></asp:TextBox>
<asp:TextBox id=txtTotal style="Z-INDEX: 108; LEFT: 192px; POSITION:
absolute; TOP: 280px" runat="server" Width="161px" Height="24px"
ReadOnly="True" BackColor="#E0E0E0"></asp:TextBox>
<asp:Button id=Button1 style="Z-INDEX: 109; LEFT: 104px; POSITION:
absolute; TOP: 317px" runat="server" Width="144px" Text="Submit
Request" Height="25px"></asp:Button></form>
</body>


Someone please help.

W.G. Ryan - MVP
Guest
 
Posts: n/a
#2: Jan 30 '06

re: Populate Table using Dataset


http://www.c-sharpcorner.com/Code/20...olumnToCal.asp
"Junior" <thundakiss@gmail.com> wrote in message
news:1138644032.752067.285090@o13g2000cwo.googlegr oups.com...[color=blue]
> Hi All,
>
> I haven't got a response for this question lately and i really need to
> get this done ASAP.
>
> I have a .aspx page that has table two column four rows on it.
> 1. How do i use codebehind C# to populate the HTML table?
> 2. How do i pull some figures from the second column and add them up in
> the Total field.
>
> here is a snipplet of the table:
> <body MS_POSITIONING="GridLayout">
> <form id=Form1 method=post runat="server">
> <table>
> <tr>
> <td>Funds to Load</td>
> <td><input style="WIDTH: 157px"
> onchange=calculateTotal name=funds></td></tr>
> <tr>
> <td style="HEIGHT: 25px">Administrative Charge</td>
> <td style="HEIGHT: 25px"><input id=admin
> style="WIDTH: 157px; HEIGHT: 22px" disabled readOnly size=21
> value=2%[color=green]
> ></td></tr>[/color]
> <tr>
> <td>Minimum Adjustment</td>
> <td><input id=minimum style="WIDTH: 157px" disabled readOnly
> value=$1000></td></tr>
> <tr>
> <td style="HEIGHT: 27px">Total Funds Required</td>
> <td style="HEIGHT: 27px"><input id=fundingTotal
> style="WIDTH: 157px" disabled readOnly value=$1000[color=green]
> ></td></tr>[/color]
> <tr>
> <td align=center colSpan=2><input type=submit value="Submit
> Request"></td></tr></table>
> <asp:Label id=Label1 style="Z-INDEX: 101; LEFT: 16px; POSITION:
> absolute; TOP: 216px" runat="server" Width="168px" Height="24px">Funds
> to Load</asp:Label>
> <asp:Label id=Label2 style="Z-INDEX: 102; LEFT: 16px; POSITION:
> absolute; TOP: 240px" runat="server" Width="176px"
> Height="24px">Administrative Charge</asp:Label>
> <asp:Label id=Label3 style="Z-INDEX: 103; LEFT: 16px; POSITION:
> absolute; TOP: 264px" runat="server" Width="168px"
> Height="24px">Minimum Adjustment</asp:Label>
> <asp:Label id=Label4 style="Z-INDEX: 104; LEFT: 16px; POSITION:
> absolute; TOP: 288px" runat="server" Width="168px" Height="16px">Total
> Funds Required</asp:Label>
> <asp:TextBox id=txtFundsToLoad style="Z-INDEX: 105; LEFT: 192px;
> POSITION: absolute; TOP: 208px" runat="server" Width="161"
> Height="24"></asp:TextBox>
> <asp:TextBox id=txtAdmin style="Z-INDEX: 106; LEFT: 192px; POSITION:
> absolute; TOP: 232px" runat="server" Width="161px" Height="24px"
> ReadOnly="True" BackColor="#E0E0E0"></asp:TextBox>
> <asp:TextBox id=txtMin style="Z-INDEX: 107; LEFT: 192px; POSITION:
> absolute; TOP: 256px" runat="server" Width="161px"
> Height="24px"></asp:TextBox>
> <asp:TextBox id=txtTotal style="Z-INDEX: 108; LEFT: 192px; POSITION:
> absolute; TOP: 280px" runat="server" Width="161px" Height="24px"
> ReadOnly="True" BackColor="#E0E0E0"></asp:TextBox>
> <asp:Button id=Button1 style="Z-INDEX: 109; LEFT: 104px; POSITION:
> absolute; TOP: 317px" runat="server" Width="144px" Text="Submit
> Request" Height="25px"></asp:Button></form>
> </body>
>
>
> Someone please help.
>[/color]


Dale
Guest
 
Posts: n/a
#3: Jan 30 '06

re: Populate Table using Dataset


First, you'll have to make your table a Server Control by adding a
runat="server" and an id=someTableName to the declaration. Then you can
access the table's Rows and Cells programmatically like this:

someTableName.Rows[0].Cells[1].InnerText = "abcde";

You would have to iterate through your list of data, keeping up with your
totals.

That said, there are a few better solutions for many circumstances:

If you have to use a table, read up on System.Web.UI.WebControls.Table.
That table is completely programmable in code with a much more complete set
of properties and methods.

Even better would be to use a DataGrid or Repeater because you can do data
binding to them. Then in your OnItemDataBound handler, you can sum your
totals and if the Item.ItemType is ListItemType.Footer, you add your text to
Item.Cells[x] where x is the member of the Cells array that you want the
total written to.

HTH
--
Dale Preston
MCAD C#
MCSE, MCDBA


"Junior" wrote:
[color=blue]
> Hi All,
>
> I haven't got a response for this question lately and i really need to
> get this done ASAP.
>
> I have a .aspx page that has table two column four rows on it.
> 1. How do i use codebehind C# to populate the HTML table?
> 2. How do i pull some figures from the second column and add them up in
> the Total field.
>
> here is a snipplet of the table:
> <body MS_POSITIONING="GridLayout">
> <form id=Form1 method=post runat="server">
> <table>
> <tr>
> <td>Funds to Load</td>
> <td><input style="WIDTH: 157px"
> onchange=calculateTotal name=funds></td></tr>
> <tr>
> <td style="HEIGHT: 25px">Administrative Charge</td>
> <td style="HEIGHT: 25px"><input id=admin
> style="WIDTH: 157px; HEIGHT: 22px" disabled readOnly size=21
> value=2%[color=green]
> ></td></tr>[/color]
> <tr>
> <td>Minimum Adjustment</td>
> <td><input id=minimum style="WIDTH: 157px" disabled readOnly
> value=$1000></td></tr>
> <tr>
> <td style="HEIGHT: 27px">Total Funds Required</td>
> <td style="HEIGHT: 27px"><input id=fundingTotal
> style="WIDTH: 157px" disabled readOnly value=$1000[color=green]
> ></td></tr>[/color]
> <tr>
> <td align=center colSpan=2><input type=submit value="Submit
> Request"></td></tr></table>
> <asp:Label id=Label1 style="Z-INDEX: 101; LEFT: 16px; POSITION:
> absolute; TOP: 216px" runat="server" Width="168px" Height="24px">Funds
> to Load</asp:Label>
> <asp:Label id=Label2 style="Z-INDEX: 102; LEFT: 16px; POSITION:
> absolute; TOP: 240px" runat="server" Width="176px"
> Height="24px">Administrative Charge</asp:Label>
> <asp:Label id=Label3 style="Z-INDEX: 103; LEFT: 16px; POSITION:
> absolute; TOP: 264px" runat="server" Width="168px"
> Height="24px">Minimum Adjustment</asp:Label>
> <asp:Label id=Label4 style="Z-INDEX: 104; LEFT: 16px; POSITION:
> absolute; TOP: 288px" runat="server" Width="168px" Height="16px">Total
> Funds Required</asp:Label>
> <asp:TextBox id=txtFundsToLoad style="Z-INDEX: 105; LEFT: 192px;
> POSITION: absolute; TOP: 208px" runat="server" Width="161"
> Height="24"></asp:TextBox>
> <asp:TextBox id=txtAdmin style="Z-INDEX: 106; LEFT: 192px; POSITION:
> absolute; TOP: 232px" runat="server" Width="161px" Height="24px"
> ReadOnly="True" BackColor="#E0E0E0"></asp:TextBox>
> <asp:TextBox id=txtMin style="Z-INDEX: 107; LEFT: 192px; POSITION:
> absolute; TOP: 256px" runat="server" Width="161px"
> Height="24px"></asp:TextBox>
> <asp:TextBox id=txtTotal style="Z-INDEX: 108; LEFT: 192px; POSITION:
> absolute; TOP: 280px" runat="server" Width="161px" Height="24px"
> ReadOnly="True" BackColor="#E0E0E0"></asp:TextBox>
> <asp:Button id=Button1 style="Z-INDEX: 109; LEFT: 104px; POSITION:
> absolute; TOP: 317px" runat="server" Width="144px" Text="Submit
> Request" Height="25px"></asp:Button></form>
> </body>
>
>
> Someone please help.
>
>[/color]
Closed Thread