Solved

Gridview ItemTemplate with If condition of Database Data

Posted on 2008-10-21
6
7,136 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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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