Convert Gridview Checkboxes to yes/no

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
jumpseatnewsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sara110Commented:
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
SystemExpertCommented:

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
TheMehrdadCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jumpseatnewsAuthor Commented:
Perfect!  Just want I needed to get the job done.  Thanks!

Chris
TheMehrdadCommented:
You are welcome,
Good luck
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.