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
Solved

Gridview ItemTemplate with If condition of Database Data

Posted on 2008-10-21
6
7,081 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 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