Solved

Gridview ItemTemplate with If condition of Database Data

Posted on 2008-10-21
6
6,906 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now