If...Then statments

J

Jagan Mohan

You can use any kind of function in the onItem_DataBound event.
There you can make use of any validations you want.

Or this was not the answer you are expecting

Thanks
Jagan Mohan
Software Engineer
 
D

DataGrid

I am looking for a solution to change this asp 3.0 code to asp.net.
The problem is the IF NOT sentence. (the blue on if you can see the color) I have everything else under controll


<Table width="600" border="0" cellspacing="0" >
<TR >
<TD width="60" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Nummer</td>
<TD width="172" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Prosjekttittel</td>
<TD width="35" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Type</td>
<TD width="63" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Status</td>
<TD width="83" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Dokument</td>
<TD width="79" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Kategori</td>
<TD width="53" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Rediger</td>
<TD width="39" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Slett</td>
</tr>
<%
do while not objR.EOF
%>
<TR>
<TD width="60" align="left" class="hoved"> <%Response.Write objR("Prosjektnummer")%></td>
<TD width="172" align="left" class="hoved">
<%Response.Write objR("Prosjekttittel")%>
</td>
<TD width="35" align="left" class="hoved">
<%Response.Write objR("Ptype_text")%>
</td>
<TD width="63" align="left" class="hoved">
<%Response.Write objR("Status_text")%>
</td>
<TD width="83" align="left" class="hoved">




<% If NOT IsNull(objR.Fields("Dokument").value) And objR.Fields("Dokument").value <> "" Then
%><a href="edit_news_item_form.asp?NewsID=<% = objR.Fields("Dokument").Value %>&ProsjektID=<%Response.Write objR("ProsjektID")%>&browser=IE">Edit</a>

<%

Else
%>
<a href="add_news_form.asp?browser=IE&ProsjektID=<%Response.Write objR("ProsjektID")%>">New</a>
<%
End If%>




</td>
<TD width="79" align="left" class="hoved">
<%Response.Write objR("Kategori")%>
</td>
<TD width="53" align="left" class="hoved"><a href="prosjekt_edit.asp?ProsjektID=<%Response.Write objR("ProsjektID")%>">Rediger</a></td>
<TD width="39" align="left" class="hoved"><a href="prosjekt_del.asp?ProsjektID=<%Response.Write objR("ProsjektID")%>" onClick="return confirm('Skal du virkelig slette?');">Slett</a></td>
</TR>
<%
objR.MoveNext ' Movenext
loop
%>
</Table>
 
S

sampsons

You need to use the function IIF([expression], Truepart, Falsepart)

Such as in IIF(objR.Fields("Dokument") Is DbNull.Value AND objR.Fields("Dokument") <> "", [Logic if both true], [Logic if either False])

Works well for Visible properties of controls also--

<asp:Button id="Button1" runat="server" visible='<%# IIF(Container.DataItem("SomeField") Is DbNull.Value, False, True)%>' />


Severin
I am looking for a solution to change this asp 3.0 code to asp.net.
The problem is the IF NOT sentence. (the blue on if you can see the color) I have everything else under controll


<Table width="600" border="0" cellspacing="0" >
<TR >
<TD width="60" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Nummer</td>
<TD width="172" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Prosjekttittel</td>
<TD width="35" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Type</td>
<TD width="63" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Status</td>
<TD width="83" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Dokument</td>
<TD width="79" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Kategori</td>
<TD width="53" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Rediger</td>
<TD width="39" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Slett</td>
</tr>
<%
do while not objR.EOF
%>
<TR>
<TD width="60" align="left" class="hoved"> <%Response.Write objR("Prosjektnummer")%></td>
<TD width="172" align="left" class="hoved">
<%Response.Write objR("Prosjekttittel")%>
</td>
<TD width="35" align="left" class="hoved">
<%Response.Write objR("Ptype_text")%>
</td>
<TD width="63" align="left" class="hoved">
<%Response.Write objR("Status_text")%>
</td>
<TD width="83" align="left" class="hoved">




<% If NOT IsNull(objR.Fields("Dokument").value) And objR.Fields("Dokument").value <> "" Then
%><a href="edit_news_item_form.asp?NewsID=<% = objR.Fields("Dokument").Value %>&ProsjektID=<%Response.Write objR("ProsjektID")%>&browser=IE">Edit</a>

<%

Else
%>
<a href="add_news_form.asp?browser=IE&ProsjektID=<%Response.Write objR("ProsjektID")%>">New</a>
<%
End If%>




</td>
<TD width="79" align="left" class="hoved">
<%Response.Write objR("Kategori")%>
</td>
<TD width="53" align="left" class="hoved"><a href="prosjekt_edit.asp?ProsjektID=<%Response.Write objR("ProsjektID")%>">Rediger</a></td>
<TD width="39" align="left" class="hoved"><a href="prosjekt_del.asp?ProsjektID=<%Response.Write objR("ProsjektID")%>" onClick="return confirm('Skal du virkelig slette?');">Slett</a></td>
</TR>
<%
objR.MoveNext ' Movenext
loop
%>
</Table>
 
J

J P Deka

If you bind data in runtime in code behind then you can easily do it.
----
Jyoti Prakash Deka
NIIT Ltd.
India



You need to use the function IIF([expression], Truepart, Falsepart)

Such as in IIF(objR.Fields("Dokument") Is DbNull.Value AND objR.Fields("Dokument") <> "", [Logic if both true], [Logic if either False])

Works well for Visible properties of controls also--

<asp:Button id="Button1" runat="server" visible='<%# IIF(Container.DataItem("SomeField") Is DbNull.Value, False, True)%>' />


Severin
I am looking for a solution to change this asp 3.0 code to asp.net.
The problem is the IF NOT sentence. (the blue on if you can see the color) I have everything else under controll


<Table width="600" border="0" cellspacing="0" >
<TR >
<TD width="60" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Nummer</td>
<TD width="172" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Prosjekttittel</td>
<TD width="35" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Type</td>
<TD width="63" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Status</td>
<TD width="83" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Dokument</td>
<TD width="79" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Kategori</td>
<TD width="53" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Rediger</td>
<TD width="39" background="../gfx/bla-60.gif" align="left" class="Overskrift2-hvit">Slett</td>
</tr>
<%
do while not objR.EOF
%>
<TR>
<TD width="60" align="left" class="hoved"> <%Response.Write objR("Prosjektnummer")%></td>
<TD width="172" align="left" class="hoved">
<%Response.Write objR("Prosjekttittel")%>
</td>
<TD width="35" align="left" class="hoved">
<%Response.Write objR("Ptype_text")%>
</td>
<TD width="63" align="left" class="hoved">
<%Response.Write objR("Status_text")%>
</td>
<TD width="83" align="left" class="hoved">




<% If NOT IsNull(objR.Fields("Dokument").value) And objR.Fields("Dokument").value <> "" Then
%><a href="edit_news_item_form.asp?NewsID=<% = objR.Fields("Dokument").Value %>&ProsjektID=<%Response.Write objR("ProsjektID")%>&browser=IE">Edit</a>

<%

Else
%>
<a href="add_news_form.asp?browser=IE&ProsjektID=<%Response.Write objR("ProsjektID")%>">New</a>
<%
End If%>




</td>
<TD width="79" align="left" class="hoved">
<%Response.Write objR("Kategori")%>
</td>
<TD width="53" align="left" class="hoved"><a href="prosjekt_edit.asp?ProsjektID=<%Response.Write objR("ProsjektID")%>">Rediger</a></td>
<TD width="39" align="left" class="hoved"><a href="prosjekt_del.asp?ProsjektID=<%Response.Write objR("ProsjektID")%>" onClick="return confirm('Skal du virkelig slette?');">Slett</a></td>
</TR>
<%
objR.MoveNext ' Movenext
loop
%>
</Table>
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top