Can I Do This
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.aspnet.

Post a new message to this list...

Wayne Wengert
I have an aspx page that includes a bound data repeater. In the ItemTemplate
section I display each row from the datasource as a set of fields in a row
in a table. e.g.:

<tr>
<td align="center"><%# DataBinder.Eval(Container,"DataItem.Group") %></td>
<td align="center"><%# DataBinder.Eval(Container,"DataItem.Count") %></td>
.....
</tr>

I want to insert a special output row whenever the value of "DataItem.Group"
changes. That extra row will span all columns and display the value of
"DataItem.Group" . I tried inserting a row with the layout I want for that
header row using the code below:

<tr id=newclass bgcolor="#ffff66" height=0>
<td height=0 colspan=8>New Class</td>
</tr>

I thought I could then catch the change in the DataItem.Group in the Item
Databind Event and change the rowheight to something like 12 and fill in the
correct text.

It turns out that even though the height is set to 0 that row displays?

Any suggestions on how to accomplish this?

Wayne

Reply to this message...
 
    
Eliyahu Goldin
Wayne,

Add runat="server" to the <tr id=newclass ... > and in ItemDataBound event
set property Visible to false. The row won't render to the client at all.

Eliyahu

"Wayne Wengert" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> I have an aspx page that includes a bound data repeater. In the
ItemTemplate
[Original message clipped]

Reply to this message...
 
    
Wayne Wengert
Eliyahu;

Thanks for the response but the <tr> and <td> elements do not have a
"visible" property?

Wayne

"Eliyahu Goldin" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Eliyahu Goldin
Wayne,

You are right. But when you add runat="server" your <tr> becomes
HtmlTableRow and <td> turns to HtmlTableCell. And they do have Visible.
Don't forget to switch to design view to get visual studio make changes to
the code-behind.

Eliyahu

"Wayne Wengert" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Wayne Wengert
Eliyahu;

I must be missing something here. I added the runat="server", switched back
to Design View and back to the HTML view but I don't see any change in the
<tr> tag nor is there a "Visible" property. When you say that it changes to
a HTMLTableRow, where does that appear? That segment of my code is as
follows:

<tr id="newclass" bgcolor="#ffff66" runat="server" height="0">
<td id="newclasscol" runat="server" colspan="8" align="center"
height="0">New Class</td>
</tr>

Wayne

"Eliyahu Goldin" <Click here to reveal e-mail address> wrote in message
news:%23Z6n$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Eliyahu Goldin
Wayne,

Sorry, I missed the point that you are doing this within ItemTemplate. You
still can set runat="server" for the <table>. Let the table build itself
with data binding and then, at the end, in PreRender event, loop through the
table, find the rows you want to hide and set for them Visible=false. You
can do it in either server script or code behind.

Eliyahu

"Wayne Wengert" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Sayed Hashimi
Wayne,

You can try this:

1) Add another row to your template, but make the row invisible.
2) Handle the item bound event to track the group. You can do this by
maintaining a class member variable.
3) When the Group changes, then make the invisible row visible.

Basically, you add an additional row to every row of the data source,
but only show the additional row when the group changes.

sayed

"Wayne Wengert" <Click here to reveal e-mail address> wrote in message news:<Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
    
Wayne Wengert
Sayed;

The problem is that there is no "visible" property on the standard <tr>

Wayne

"Sayed Hashimi" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Web.UI.DataBinder
System.Web.UI.HtmlControls.HtmlTableCell
System.Web.UI.HtmlControls.HtmlTableRow




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com