Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 17th, 2007, 07:33 AM
Authorized User
 
Join Date: Jan 2007
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliirfan84
Default Checkbox in GridView

I want to use checkbox in grid view in unbound mode.The field in database against which I want to check or uncheck this checkbox is string('Y','N'). Please tell me how to use string data to check and uncheck checkbox in grid view.

__________________
Regards,
Ali Irfan
 
Old May 15th, 2007, 03:59 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
You can add a TemplateField in your aspx file

<asp:TemplateField HeaderText="Incluir">
     <ItemTemplate>
     <asp:CheckBox ID="chkbox1" runat="server" Checked='<%# ConvierteBoolean(Eval("INCLUIR")) %>' />
      </ItemTemplate>
</asp:TemplateField>

This field is related with a database field called "INCLUIR" it is a string field that contains Y or N

In the code behind you need to crea the function called "ConvierteBoolean", something like this:

Protected Function ConvierteBoolean(ByVal valor As String) As Boolean
        If valor = "Y" Then
            Return True
        Else
            Return False
        End If
    End Function

Hopefully this can help you.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview and Checkbox krasnokojiy ASP.NET 2.0 Basics 14 February 28th, 2008 12:56 PM
Confirmation with checkbox in gridview collie Visual Studio 2005 0 October 24th, 2007 06:13 AM
Checkbox in Gridview yukijocelyn ASP.NET 2.0 Basics 0 September 24th, 2007 12:32 AM
GridView Checkbox ItemTemplate angelicagm ASP.NET 2.0 Professional 3 May 31st, 2007 04:44 AM
Gridview checkbox problems pauliehaha ASP.NET 2.0 Professional 1 May 3rd, 2007 04:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.