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. change GridViews ColumnStyles Programmatically in Codebehind

change GridViews ColumnStyles Programmatically in Codebehind

Scheduled Pinned Locked Moved ASP.NET
csharphelp
5 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.
  • F Offline
    F Offline
    freshonlineMax
    wrote on last edited by
    #1

    Hello I'm sure you saw this request fro several times, but please help me. i'm a Windows Application Developer (C#) and i always change properties of controls programmatically. i did these: sqlDatasource1.Connectionstring = ... ; sqlDataSource1.SelectCommand = "SELECT idn, header, date FROM tblNews'; sqlDataSource1.DataBind(); gridView1.dataSourceID = sqlDataSource1; gridView1.DataBind(); Now i want to do these in CodeBehind: 1-Change columns HeaderText and width 1-Change column[1] (header) to HyperLink 2-Add Button with Text="Active', Identify when user clicks on it and it's RowId I know it takes time for helping me, Please take me usefull references in web. Tanx

    M G 2 Replies Last reply
    0
    • F freshonlineMax

      Hello I'm sure you saw this request fro several times, but please help me. i'm a Windows Application Developer (C#) and i always change properties of controls programmatically. i did these: sqlDatasource1.Connectionstring = ... ; sqlDataSource1.SelectCommand = "SELECT idn, header, date FROM tblNews'; sqlDataSource1.DataBind(); gridView1.dataSourceID = sqlDataSource1; gridView1.DataBind(); Now i want to do these in CodeBehind: 1-Change columns HeaderText and width 1-Change column[1] (header) to HyperLink 2-Add Button with Text="Active', Identify when user clicks on it and it's RowId I know it takes time for helping me, Please take me usefull references in web. Tanx

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      Hi, Instead of creating columns automattically at runtime. You can create the custom columns. Go to property builder of gridview and the uncheck the Automatically create columns at runtime. Add the desired columns there giving desired header name and datafield.

      F 1 Reply Last reply
      0
      • F freshonlineMax

        Hello I'm sure you saw this request fro several times, but please help me. i'm a Windows Application Developer (C#) and i always change properties of controls programmatically. i did these: sqlDatasource1.Connectionstring = ... ; sqlDataSource1.SelectCommand = "SELECT idn, header, date FROM tblNews'; sqlDataSource1.DataBind(); gridView1.dataSourceID = sqlDataSource1; gridView1.DataBind(); Now i want to do these in CodeBehind: 1-Change columns HeaderText and width 1-Change column[1] (header) to HyperLink 2-Add Button with Text="Active', Identify when user clicks on it and it's RowId I know it takes time for helping me, Please take me usefull references in web. Tanx

        G Offline
        G Offline
        ganti r
        wrote on last edited by
        #3

        Hi Max, Check this link. It is given in detail how you can create columns dynamically. http://www.123aspx.com/redir.aspx?res=35975

        rAm i Think, i Wait, i Fast -- Siddartha

        1 Reply Last reply
        0
        • M Manas Bhardwaj

          Hi, Instead of creating columns automattically at runtime. You can create the custom columns. Go to property builder of gridview and the uncheck the Automatically create columns at runtime. Add the desired columns there giving desired header name and datafield.

          F Offline
          F Offline
          freshonlineMax
          wrote on last edited by
          #4

          Hello Friends How can i know which row user clicked on it? I saw in forums they use CommandClick with e.command argument, but i can't see this event for GridView in Properties box! I don't want to use Select Column of GridView. Tanx

          M 1 Reply Last reply
          0
          • F freshonlineMax

            Hello Friends How can i know which row user clicked on it? I saw in forums they use CommandClick with e.command argument, but i can't see this event for GridView in Properties box! I don't want to use Select Column of GridView. Tanx

            M Offline
            M Offline
            Manas Bhardwaj
            wrote on last edited by
            #5

            Trap the CellMouseClick event... You can then use the e.RowIndex to know the row clicked by the user.:->

            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