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?
 
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
0
 
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
0
 
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
0
 
jumpseatnewsAuthor Commented:
Perfect!  Just want I needed to get the job done.  Thanks!

Chris
0
 
TheMehrdadCommented:
You are welcome,
Good luck
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.