G
GD
I need to bind my repeater to a DataSet for which the number of columns
is always different (cross-tab report). However, I need to exlude an Id
column from displaying on the Repeater. As shown below, I'm not
specifying each column to display so I can't simply not include that
column. I also can't physically remove that column from the DataTable
because it is the parent column in a DataRelation.
Here's what my Repeater looks like on the aspx side (I got a lot of
help on this from Joshua Mitts on this group)
<asp:Repeater ID="rptCompanies" Runat="server"
OnItemDataBound="rptCompanies_OnItemDataBound">
<ItemTemplate>
<tr>
<asp:Repeater ID="rptCompanyActivity" Runat="server">
<ItemTemplate>
<td><%# (object) Container.DataItem %></td>
</ItemTemplate>
</asp:Repeater>
</tr>
</asp:Repeater>
On Page_Load I'm doing this:
rptCompanies.DataSource = dsRpt.Tables["Company"].Rows;
rptCompanies.DataBind();
and on rptCompanies_OnItemDataBound
DataRow drCompany = (DataRow) e.Item.DataItem;
object [] oCompanyCols = drCompany.ItemArray;
Repeater rptCompanyActivity = (Repeater)
e.Item.FindControl("rptCompanyActivity");
rptCompanyActivity.DataSource = oCompanyCols;
rptCompanyActivity.DataBind();
I think the key to this is going to be in setting the DataSource of
rptCompanies. However, I don't think I can use the DataTable.Select
method to select certain column names, but just to filter my Rows.
is always different (cross-tab report). However, I need to exlude an Id
column from displaying on the Repeater. As shown below, I'm not
specifying each column to display so I can't simply not include that
column. I also can't physically remove that column from the DataTable
because it is the parent column in a DataRelation.
Here's what my Repeater looks like on the aspx side (I got a lot of
help on this from Joshua Mitts on this group)
<asp:Repeater ID="rptCompanies" Runat="server"
OnItemDataBound="rptCompanies_OnItemDataBound">
<ItemTemplate>
<tr>
<asp:Repeater ID="rptCompanyActivity" Runat="server">
<ItemTemplate>
<td><%# (object) Container.DataItem %></td>
</ItemTemplate>
</asp:Repeater>
</tr>
</asp:Repeater>
On Page_Load I'm doing this:
rptCompanies.DataSource = dsRpt.Tables["Company"].Rows;
rptCompanies.DataBind();
and on rptCompanies_OnItemDataBound
DataRow drCompany = (DataRow) e.Item.DataItem;
object [] oCompanyCols = drCompany.ItemArray;
Repeater rptCompanyActivity = (Repeater)
e.Item.FindControl("rptCompanyActivity");
rptCompanyActivity.DataSource = oCompanyCols;
rptCompanyActivity.DataBind();
I think the key to this is going to be in setting the DataSource of
rptCompanies. However, I don't think I can use the DataTable.Select
method to select certain column names, but just to filter my Rows.