Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Adding CheckBox in ASP.NET

Adding CheckBox in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelpasp-net
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zeeshan Ahmed Memon
    wrote on last edited by
    #1

    Dear Programmers, I need your help. I am developing a project in ASP.NET in which I am using VB.NET as Language. I want to add CheckBox in DataGrid. Even I am succeded in showing the checkbox in Datagrid but I am unable to give the user opportunity to select the checkboxes. The checkbox field directly checks or unchecks the checkbox by getting data from one of the column of my database. My database is in SQL Server 2000. Please help me. I am also sending the scripting code below. <%@ Page Language="VB" %>

    CheckBoxField Example
    

    CheckBoxField Example

    please check the code and tell me where i am doing mistake so that i shall correct it. Please Remember that I am using Visual Studio 2005 as an editor to code ASP.NET. If you solve the problem then please inform me on the following ID: zeeshan_st2003@yahoo.com Thankyou. Waiting for your reply. One of your Programmer Friend, Zeeshan Ahmad.

    T M 2 Replies Last reply
    0
    • Z Zeeshan Ahmed Memon

      Dear Programmers, I need your help. I am developing a project in ASP.NET in which I am using VB.NET as Language. I want to add CheckBox in DataGrid. Even I am succeded in showing the checkbox in Datagrid but I am unable to give the user opportunity to select the checkboxes. The checkbox field directly checks or unchecks the checkbox by getting data from one of the column of my database. My database is in SQL Server 2000. Please help me. I am also sending the scripting code below. <%@ Page Language="VB" %>

      CheckBoxField Example
      

      CheckBoxField Example

      please check the code and tell me where i am doing mistake so that i shall correct it. Please Remember that I am using Visual Studio 2005 as an editor to code ASP.NET. If you solve the problem then please inform me on the following ID: zeeshan_st2003@yahoo.com Thankyou. Waiting for your reply. One of your Programmer Friend, Zeeshan Ahmad.

      T Offline
      T Offline
      Tokorie
      wrote on last edited by
      #2

      Do you need the Checkbox to be dynamically checked or unchecked during databinding ?? Or do you mean you want the checkbox to be fire when user makes a selection in another column in the grid?? For the first, you can attach the value from the datage to the Checked event of the checkbox, so if the value bound is in bit/boolean form from the database, that sets the checked event of the checkbox to false or true. For the second, you can set it in the such a way that when the user makes a selection in the column that determins the value of the state of the checkbox, based on selection, you either check or uncheck the checkbox in your grid

      1 Reply Last reply
      0
      • Z Zeeshan Ahmed Memon

        Dear Programmers, I need your help. I am developing a project in ASP.NET in which I am using VB.NET as Language. I want to add CheckBox in DataGrid. Even I am succeded in showing the checkbox in Datagrid but I am unable to give the user opportunity to select the checkboxes. The checkbox field directly checks or unchecks the checkbox by getting data from one of the column of my database. My database is in SQL Server 2000. Please help me. I am also sending the scripting code below. <%@ Page Language="VB" %>

        CheckBoxField Example
        

        CheckBoxField Example

        please check the code and tell me where i am doing mistake so that i shall correct it. Please Remember that I am using Visual Studio 2005 as an editor to code ASP.NET. If you solve the problem then please inform me on the following ID: zeeshan_st2003@yahoo.com Thankyou. Waiting for your reply. One of your Programmer Friend, Zeeshan Ahmad.

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #3

        Zeeshan Memon wrote:

        asp:checkboxfield datafield="contract" text="Contract" headertext="Contract"

        Have you read this?

        Note from MSDN example

        Because a check box can display only a selected or an unselected state, a CheckBoxField object can be bound only to a field with a Boolean data type or a string that can be parsed by Parse.

        So, if "contract" field is boolean type then the checkedbox will display a selected or unselected automatically.. If your field is a string type and the data from that column is not "1" or "0" then ~ - Try to change this column to template column - Add one more hidden label in that column and set the datafield of this label to the database field (e.g. "contract") - In Item_bound event, find this label and check/uncheck the checked box accordingly. e.g. Label l = e.FindControl("myhiddenlabel"); CheckedBox c = e.FindControl("chkBoxContract"); if (l.Text == "abc"){ c.Checked = true; } P.S: I wrote this example just like that here without checking in Visual studio.. but you may get some ideas from this code.. Hope it helps..

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups