Need help with populating table control with data from a data set

G

Guest

Hi,

I don't have much knowledge of the table control. I am basically trying to
use a table thats populated with data rows from a dataSet but currently
things aren't working for me.

below is the sample HTML that I have:

<asp:TableRow>
<asp:TableCell Text="Company" ID="CompanyCode"
Runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="Paygroup" ID="PaygroupCode"
Runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="paygroup descr" ID="PaygroupDescr"
Runat="server"></asp:TableCell>
</asp:TableRow>

------------

In addition, I think I need some VB code to assign the particular data rows
to the table columns, but I'm not sure of the syntax:

Table1.ID("Company") = Dr("Company")

Any help would be much appreciated.


Thanks,

Gavin
 
E

Eliyahu Goldin

Gavin,

If for whatever reason you are not happy with the datagrid that would do all
the work for you, you can use a repeater and setup the itemtemplate to
resemble the table row (<tr>) with the cells (<td>s) bound to the dataset
columns.

Eliyahu
 
G

Guest

Hi Eliyahu,

Thanks for your help.

Can you please give me an idea of how the syntax would kind of look using a
"repeater"?

Thanks,

Gavin
P.S.--The reason why I don't want to use a datagrid is because I'm trying to
put in logic that collapses rows when there are values of zero or null. I
don't think a datagrid can do this.
 
E

Eliyahu Goldin

Ok, here is a fregment taken from one of my pages.

<table id="tblCharges" width="100%" cellspacing="3"
style="table-layout:fixed;background-color:#f0ffff">
<colgroup>
<col width="3ex">
<col width="8ex" class="SelectionGridItem">
<col width="18ex" class="SelectionGridItem">
<col width="10ex" class="SelectionGridItem">
<col width="10ex" class="SelectionGridItem">
</colgroup>
<asp:Repeater Runat="server" id="dgCharges" DataSource="<%#
DSChartCharges %>" DataMember="tblChartCharges"
OnItemDataBound="dgCharges_ItemDataBound" >
<HeaderTemplate>
<tr>
<td>&nbsp;</td>
<td class="SelectionGridHeader">CPT</td>
<td class="SelectionGridHeader">Mod</td>
<td class="SelectionGridHeader">ICD-9</td>
<td class="SelectionGridHeader">ICD-9</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><span runat="server" id="lblNumber"><%#
((DataRowView)Container.DataItem) ["Rank"] %></span></td>
<td><input type="text" Runat="server" id=txtCpt
class="ChargeInput"
value='<%# ((DataRowView)Container.DataItem) ["CptCode"] %>'
onfocus="codeGotFocus()" onblur="codeLostFocus()"
onkeypress="return keyPressed();"></td>
<td><input type="text" Runat="server" id="txtMods"
class="ChargeInput"
onfocus="modsGotFocus()" onblur="modsLostFocus()"
onkeypress="return keyPressed();"></td>
<td><input type="text" Runat="server" id="txtIcd91"
class="ChargeInput"
value='<%# ((DataRowView)Container.DataItem) ["Icd91"] %>'
onfocus="codeGotFocus()" onblur="codeLostFocus()"
onkeypress="return keyPressed();"></td>
<td><input type="text" Runat="server" id="txtIcd92"
class="ChargeInput"
value='<%# ((DataRowView)Container.DataItem) ["Icd92"] %>'
onfocus="codeGotFocus()" onblur="codeLostFocus()"
onkeypress="return keyPressed();"></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table


Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top