[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert Gridview Checkboxes to yes/no

Posted on 2006-04-16
5
Medium Priority
?
700 Views
Last Modified: 2012-05-05
Hi,

I have the following code in my gridview:

        <asp:TemplateField HeaderText="Active?" SortExpression="Active">
            <EditItemTemplate>
                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Active") %>' />
            </EditItemTemplate>
            <ItemTemplate>
                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Active") %>' Enabled="false" />
            </ItemTemplate>
        </asp:TemplateField>

How can I get it to say 'Yes' or 'No' instead of displaying the checkboxes?

I'm using VB.NET.

Chris
0
Comment
Question by:jumpseatnews
5 Comments
 
LVL 6

Expert Comment

by:sara110
ID: 16466947
what is your column type in Database, if it is Yes No why don't you bind it to a label, then it shows what you really want. and if your clients shouldn't checked it
0
 
LVL 10

Expert Comment

by:SystemExpert
ID: 16467185

Hi,

If you don't want to that column as CheckBox

Then Modify your select statement like this ( Here I assume your field takes 0 and 1 for yes/No)

Select field1,field2,field3,iif(field4=1,'Yes',No)as Status from YourTable Where<condition>

Now you bind this Status column to your datagrid and display it

Thanks
0
 
LVL 5

Accepted Solution

by:
TheMehrdad earned 2000 total points
ID: 16467243
Dear jumpseatnews,
Change the code to:

       <asp:TemplateField HeaderText="Active?" SortExpression="Active">
            <EditItemTemplate>
                <asp:Label ID="Label1" runat="server"><%= IIF(Evaluate("Active"),"Yes","No") %></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server"><%= IIF(Evaluate("Active"),"Yes","No") %></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>

Good luck
0
 

Author Comment

by:jumpseatnews
ID: 16468035
Perfect!  Just want I needed to get the job done.  Thanks!

Chris
0
 
LVL 5

Expert Comment

by:TheMehrdad
ID: 16469327
You are welcome,
Good luck
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

830 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