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. Gridview Questions

Gridview Questions

Scheduled Pinned Locked Moved ASP.NET
databasequestion
4 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.
  • K Offline
    K Offline
    kallileo
    wrote on last edited by
    #1

    I display some boolean values in checkboxes. Is it possible instead of the checkboxes the values to displayed as On if the database cell=True or Off if the value=False. Also if all the values in a column are the same e.g kjaslklkajl. Is it possible to represent this colunm with different value? kjaslklkajl=Some Name. Thanks

    S C 2 Replies Last reply
    0
    • K kallileo

      I display some boolean values in checkboxes. Is it possible instead of the checkboxes the values to displayed as On if the database cell=True or Off if the value=False. Also if all the values in a column are the same e.g kjaslklkajl. Is it possible to represent this colunm with different value? kjaslklkajl=Some Name. Thanks

      S Offline
      S Offline
      Spunky Coder
      wrote on last edited by
      #2

      How come you are displaying values in the checkboxes? U'r question is not clear ...

      Koushik

      1 Reply Last reply
      0
      • K kallileo

        I display some boolean values in checkboxes. Is it possible instead of the checkboxes the values to displayed as On if the database cell=True or Off if the value=False. Also if all the values in a column are the same e.g kjaslklkajl. Is it possible to represent this colunm with different value? kjaslklkajl=Some Name. Thanks

        C Offline
        C Offline
        Chetan Ranpariya
        wrote on last edited by
        #3

        HI, Make autogeneratecolumns property of gridview to false. and create for each of the column you need to display. This way your boolean column will display "True" and "False" in the gridview. Now you can change this to "On" and "Off" by writing code in the "RowDataBound" event of the gridview. protected void gvDemo_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[2].Text == "True") { e.Row.Cells[2].Text = "On"; } else { e.Row.Cells[2].Text = "Off"; } } } set OnRowDataBound = "gvDemo_RowDataBound" in the gridview. The code for your sencond problem can also be written here only cellindex will be changed. I hope this will help you. Thanks and Regards, Chetan Ranpariya

        K 1 Reply Last reply
        0
        • C Chetan Ranpariya

          HI, Make autogeneratecolumns property of gridview to false. and create for each of the column you need to display. This way your boolean column will display "True" and "False" in the gridview. Now you can change this to "On" and "Off" by writing code in the "RowDataBound" event of the gridview. protected void gvDemo_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[2].Text == "True") { e.Row.Cells[2].Text = "On"; } else { e.Row.Cells[2].Text = "Off"; } } } set OnRowDataBound = "gvDemo_RowDataBound" in the gridview. The code for your sencond problem can also be written here only cellindex will be changed. I hope this will help you. Thanks and Regards, Chetan Ranpariya

          K Offline
          K Offline
          kallileo
          wrote on last edited by
          #4

          I use VB.net but this code is exactly what I need. Thank you guys.

          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