Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a Conditional Statement in the Markup 1

Status
Not open for further replies.

faust13

Programmer
Aug 7, 2001
176
US
I'm sure this is simple, but can someone tell me how to do a conditional in the mark-up of the ASP.Net page?

Example (Beware psuedo code):

<% if(Request.queryString["myVal"])
{
<tr>
<td style="width: 100px">
<asp:Label ID="Label7" runat="server" Text="Arrival Date"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="txtArrivalDate" runat="server"></asp:TextBox></td>
<td style="width: 100px">
</td>
</tr>
} %>



Thanks,

faust13
Because Han Shoots First
 
You would do it in the Data Bound event of whichever control you are are using (i.e Repeater, GridView etc). Have a look at the help files for this event on whichever control it is you are using.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I'm not using a databound control. I'm trying to hide a row of a table conditionally.

If there's a better way to approach this, please share.


Thanks,

faust13
Because Han Shoots First
 
use a server side table.. and add ids to each row and/or column.. then you can refernce them by name and hide and show as necessary in the code behind

In line coding is classic ASP programming.. use the code behind in asp.net

 
Thanks, I'll check that out. I've been thrown into ASP.Net development from J2EE/CF. I did classic ASP ages ago, so I'm learning a lot of new tricks. Thanks for bearing with me.


Thanks,

faust13
Because Han Shoots First
 
use a server side table.. and add ids to each row and/or column
You can also use a HTMLTable and just add an ID and runat="server". Then you can access the relevant rows via the index of the Rows Property (this also applies to a server-side table) rather than having to add and id to each row/column.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top