Professional Web Applications Themes

If...Then statments - ASP.NET Data Grid Control

Hi, How can I use a If..Then Statment in DataGrid?...

Sponsored Links
  1. #1

    Default If...Then statments

    Hi,
    How can I use a If..Then Statment in DataGrid?


    Sponsored Links
    DataGrid Guest

  2. #2

    Default Re: If...Then statments

    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


    "DataGrid" <eirikrothe.no> wrote in message
    news:O6gsGyxQDHA.1624tk2msftngp13.phx.gbl...
    > Hi,
    > How can I use a If..Then Statment in DataGrid?
    >
    >

    Jagan Mohan Guest

  3. #3

    Default Re: If...Then statments

    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=<%Re sponse.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.Writ e 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>


    "Jagan Mohan" <jagan.mohanscapevelocity.com> skrev i melding news:urkkW5zQDHA.2648TK2MSFTNGP10.phx.gbl...
    > 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
    >
    >
    > "DataGrid" <eirikrothe.no> wrote in message
    > news:O6gsGyxQDHA.1624tk2msftngp13.phx.gbl...
    > > Hi,
    > > How can I use a If..Then Statment in DataGrid?
    > >
    > >
    >
    >
    DataGrid Guest

  4. #4

    Default Re: If...Then statments

    check out this article,
    [url]http://www.microsoft.com/india/msdn/articles/SolutionstoTopFourQuestions.aspx[/url]

    In this article, check the sub heading Manipulating DataSource Values while binding to DataGrid which might help you

    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "DataGrid" <eirikrothe.no> wrote in message news:OR8yJG2QDHA.1624tk2msftngp13.phx.gbl...
    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=<%Re sponse.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.Writ e 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>


    "Jagan Mohan" <jagan.mohanscapevelocity.com> skrev i melding news:urkkW5zQDHA.2648TK2MSFTNGP10.phx.gbl...
    > 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
    >
    >
    > "DataGrid" <eirikrothe.no> wrote in message
    > news:O6gsGyxQDHA.1624tk2msftngp13.phx.gbl...
    > > Hi,
    > > How can I use a If..Then Statment in DataGrid?
    > >
    > >
    >
    >
    Saravana Guest

  5. #5

    Default Re: If...Then statments

    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
    "DataGrid" <eirikrothe.no> wrote in message news:OR8yJG2QDHA.1624tk2msftngp13.phx.gbl...
    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=<%Re sponse.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.Writ e 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>


    "Jagan Mohan" <jagan.mohanscapevelocity.com> skrev i melding news:urkkW5zQDHA.2648TK2MSFTNGP10.phx.gbl...
    > 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
    >
    >
    > "DataGrid" <eirikrothe.no> wrote in message
    > news:O6gsGyxQDHA.1624tk2msftngp13.phx.gbl...
    > > Hi,
    > > How can I use a If..Then Statment in DataGrid?
    > >
    > >
    >
    >
    sampsons Guest

  6. #6

    Default Re: If...Then statments

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



    "sampsons" <sampsonsairmail.net> wrote in message news:behp32$28nlibrary2.airnews.net...
    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
    "DataGrid" <eirikrothe.no> wrote in message news:OR8yJG2QDHA.1624tk2msftngp13.phx.gbl...
    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=<%Re sponse.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.Writ e 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>


    "Jagan Mohan" <jagan.mohanscapevelocity.com> skrev i melding news:urkkW5zQDHA.2648TK2MSFTNGP10.phx.gbl...
    > 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
    >
    >
    > "DataGrid" <eirikrothe.no> wrote in message
    > news:O6gsGyxQDHA.1624tk2msftngp13.phx.gbl...
    > > Hi,
    > > How can I use a If..Then Statment in DataGrid?
    > >
    > >
    >
    >
    J P Deka Guest

Similar Threads

  1. SQL statments that don,t output correctly
    By JanyerCFML in forum Coldfusion Database Access
    Replies: 4
    Last Post: April 19th, 04:41 PM
  2. Flash Forms with cfif statments?
    By webcommunic8or in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: February 18th, 02:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139