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. How display like that in gridview?

How display like that in gridview?

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorialquestion
7 Posts 5 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.
  • I Offline
    I Offline
    indiaone
    wrote on last edited by
    #1

    Hi. From Database i m getting data in this format. CAC PAT A 12/03/07 CAC PAT A 12/04/07 CAC PAT A 12/05/07 CMP CAT B 11/03/07 CMP CAT B 11/06/07 CMP CAT B 11/08/07 CPL AMT C 10/01/07 CPL AMT C 10/04/07 CPL AMT C 10/06/07 I want to display like that CAC PAT A 12/03/07 12/04/07 12/05/07 CMP CAT B 11/03/07 11/06/07 11/08/07 CPL AMT C 10/01/07 10/04/07 10/06/07 How to do ? Help me Thanks

    V L 2 Replies Last reply
    0
    • I indiaone

      Hi. From Database i m getting data in this format. CAC PAT A 12/03/07 CAC PAT A 12/04/07 CAC PAT A 12/05/07 CMP CAT B 11/03/07 CMP CAT B 11/06/07 CMP CAT B 11/08/07 CPL AMT C 10/01/07 CPL AMT C 10/04/07 CPL AMT C 10/06/07 I want to display like that CAC PAT A 12/03/07 12/04/07 12/05/07 CMP CAT B 11/03/07 11/06/07 11/08/07 CPL AMT C 10/01/07 10/04/07 10/06/07 How to do ? Help me Thanks

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      Use ItemDataBound Event of GridView.

      I 1 Reply Last reply
      0
      • V varshavmane

        Use ItemDataBound Event of GridView.

        I Offline
        I Offline
        indiaone
        wrote on last edited by
        #3

        thanks for reply can you explain it thanks

        S V 2 Replies Last reply
        0
        • I indiaone

          thanks for reply can you explain it thanks

          S Offline
          S Offline
          Sathesh Sakthivel
          wrote on last edited by
          #4

          Try this is the code which i used for it. private void DG_ItemDataBound(object o, DataGridItemEventArgs e) { // apply custom formatting to data cells if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // set formatting for the category cell TableCell cell = (e.Item.Controls[0] as TableCell); cell.Width = new Unit("120px"); cell.Style["border-right"] = "2px solid #666666"; cell.BackColor = System.Drawing.Color.LightGray; // set formatting for value cells for(int i=1; i= 8000) and apply special highlighting if (GetCellValue(cell) >= 8000) { cell.Font.Bold = true; cell.BorderWidth = new Unit("1px"); cell.BorderColor = System.Drawing.Color.Gray; cell.BorderStyle = BorderStyle.Dotted; cell.BackColor = System.Drawing.Color.Honeydew; } } } // apply custom formatting to the header cells if (e.Item.ItemType == ListItemType.Header) { foreach (TableCell cell in e.Item.Controls) { cell.Style["border-bottom"] = "2px solid #666666"; cell.BackColor=System.Drawing.Color.LightGray; } } } It is an Example only try it with your specs.

          SSK.

          N 1 Reply Last reply
          0
          • I indiaone

            thanks for reply can you explain it thanks

            V Offline
            V Offline
            varshavmane
            wrote on last edited by
            #5

            Item Data Bound is the event which is fired before u bind the GridView Control, so either u can fire a query where u will get the ID and Different dates and then match that ID with the e.Row.Cells[0].Text and do something like this: e.Row.Cells[1].Text= //Put all the different date in a string variable separated by
            Before this u will have to write the above code in this if statement: if (e.Row.RowType == DataControlRowType.DataRow) { } I am not sure about the syntax. But u can get it. Hope u understood the code.

            1 Reply Last reply
            0
            • I indiaone

              Hi. From Database i m getting data in this format. CAC PAT A 12/03/07 CAC PAT A 12/04/07 CAC PAT A 12/05/07 CMP CAT B 11/03/07 CMP CAT B 11/06/07 CMP CAT B 11/08/07 CPL AMT C 10/01/07 CPL AMT C 10/04/07 CPL AMT C 10/06/07 I want to display like that CAC PAT A 12/03/07 12/04/07 12/05/07 CMP CAT B 11/03/07 11/06/07 11/08/07 CPL AMT C 10/01/07 10/04/07 10/06/07 How to do ? Help me Thanks

              L Offline
              L Offline
              Lucky Sheikh
              wrote on last edited by
              #6

              hey guy first of all where u want to display the format in crystal or other if in crystal report make a group go to group insert group select the datatable column name it will be work. byeeeeeeeee lucky

              1 Reply Last reply
              0
              • S Sathesh Sakthivel

                Try this is the code which i used for it. private void DG_ItemDataBound(object o, DataGridItemEventArgs e) { // apply custom formatting to data cells if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // set formatting for the category cell TableCell cell = (e.Item.Controls[0] as TableCell); cell.Width = new Unit("120px"); cell.Style["border-right"] = "2px solid #666666"; cell.BackColor = System.Drawing.Color.LightGray; // set formatting for value cells for(int i=1; i= 8000) and apply special highlighting if (GetCellValue(cell) >= 8000) { cell.Font.Bold = true; cell.BorderWidth = new Unit("1px"); cell.BorderColor = System.Drawing.Color.Gray; cell.BorderStyle = BorderStyle.Dotted; cell.BackColor = System.Drawing.Color.Honeydew; } } } // apply custom formatting to the header cells if (e.Item.ItemType == ListItemType.Header) { foreach (TableCell cell in e.Item.Controls) { cell.Style["border-bottom"] = "2px solid #666666"; cell.BackColor=System.Drawing.Color.LightGray; } } } It is an Example only try it with your specs.

                SSK.

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Exactly copied from this[^]. Shame on you


                My Website | Ask smart questions

                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