Solved

Gridview ItemTemplate with If condition of Database Data

Posted on 2008-10-21
6
7,254 Views
Last Modified: 2012-05-05
Dear Experts
In Gridview I would like to use check Box If condtion is true other wise Label with Text

    <ItemTemplate>
                  <%# (If (Eval("submitCd"))=0 Then) %>
                    <asp:CheckBox ID="chkStatus" runat="server" />
                    <%# else %>
                    <asp:Label ID="lblStatus" runat="server" Text="Submitted" />
                      <%#end if) %>
                  </ItemTemplate>

SubmitCd is a database field, when user submit his Timesheet the value is updated as 1, so on when Approver Approve SubmitCd value updated to 3, accordingly I would like change the LblStatus Text.

If he did not submit, there should be  checkbox, by which user can checked and click submit button to submit.

I already this in ASP but dont know how to do in ASP.Net.

Regards
0
Comment
Question by:samijsr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 18

Accepted Solution

by:
David Robitaille earned 125 total points
ID: 22767655
you should toggle the Visible property instead

<asp:CheckBox ID="chkStatus" runat="server" visible='<%# (Eval("submitCd")=0) %>'/>
 

Open in new window

0
 
LVL 4

Author Closing Comment

by:samijsr
ID: 31508277
Thanks buddy
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22786242
Could i know, why does it get a "B", if it resolve the issue, I think I should get a "A".
Please read this:
http://www.experts-exchange.com/help.jsp#hi403
abstract: "an answer is worth an A, unless it doesn't resolve your issue"
 
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:samijsr
ID: 22786461
Dear Friend,
I rate this as "B" cause it is not he exact solution I am looking for.
This code is helpful for single if condition, but actually me requirement is for nested If as I did in ASP.

Might be Grid view doesn,t flexible enogh to handle nested If condition, I am not sure.

Regards

Sami

0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22786588

it`s beacues ASP.net woks differently than classic ASP.
the <%#  %> dont works like in asp. And no, it dosent work for nested If.
I provided only one side of the if because the other side is trivial.
you could do nested if in the "databinded" event of the of the gridview row to achive the same goal.
Next time, if the answer dose not fulfill your need, please seen some feedback so experts could provide an more complete answer. Also, if you grade lower than "A", please provide some "Grading comments" that explain why.
It s not because I`m angry, I just want to know so I will be better next time...
0
 
LVL 4

Author Comment

by:samijsr
ID: 22786980
Thanks dear,

I will do same.

Regards
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question