• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 568
  • Last Modified:

.net C# repeater - conditional control

.net C# repeater - conditional control
I have a repeater control.
Based on certain data ( a flag) from the same database SELECT results which returned Tom, Dick and Harry;
I want to prevent the Tom row from displaying something like this:
if(flagdata !="notom"){
<tr>
 <td> Tom </td> <td><% # bounddata %></td>
</tr>
}
<tr>
 <td> dick </td> <td><% # bounddata %></td>
</tr>
<tr>
 <td> harry </td> <td><% # bounddata %></td>
</tr>

new to .net and repeate how do the experts do this??

HELP!
0
RSSIAdmin
Asked:
RSSIAdmin
  • 2
1 Solution
 
dmagliolaCommented:
Can you clarify your problem a little bit more?

The way I understand it, there are certain rows that you don't want to show, based on the data in the table.
If that is the case, you can filter the table to remove (or hide) these rows BEFORE databinding.

Please let me know if this would be possible or not, or whether I have misunderstood the question.
0
 
RSSIAdminAuthor Commented:
dmagliola: Your right,  but I want the balance of the data in the returned row to be display in the HTML repeater table. For example if Tom is flagged not to show.  I want the repeater table  to omit the Tom row and just display the balance of the data returned,  in this case just the Dick and Harry rows.

I want this ( note that the Tom row does not appear) i
<tr>
 <td> dick </td> <td><% # bounddata %></td>
</tr>
<tr>
 <td> harry </td> <td><% # bounddata %></td>
</tr>

<tr>
 <td> harry </td> <td><% # bounddata %></td>
</tr>

I don't want the table to look like this:
<tr>
 <td> Tom </td> <td></td>
</tr>
<tr>
 <td> dick </td> <td><% # bounddata %></td>
</tr>
<tr>
 <td> harry </td> <td><% # bounddata %></td>
</tr>

Sorry if I am not clear.
0
 
dmagliolaCommented:
Yes you are clear.
If you filter the data before data binding, the row will not show up, because it will not even exist :-)
You can filter it out using a WHERE in the SELECT clause, if you're from a database.

If for some reason you can't filter at the database level, then when you get the data in a DataTable, you can either recurse through its rows and delete the ones you don't want, or use a DataView to filter them out.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now