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. display different item in the cell under same column

display different item in the cell under same column

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
9 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.
  • G Offline
    G Offline
    glad_to_be_here
    wrote on last edited by
    #1

    Hi : Anyone had experience displaying different items under:confused: same column ? for example, display image on column1, row 1; display dropdown on column1, row 2. I figured that template is not a good idea here. Am I right ? any suggesions ? Thanks!

    D L 2 Replies Last reply
    0
    • G glad_to_be_here

      Hi : Anyone had experience displaying different items under:confused: same column ? for example, display image on column1, row 1; display dropdown on column1, row 2. I figured that template is not a good idea here. Am I right ? any suggesions ? Thanks!

      D Offline
      D Offline
      Dr_X
      wrote on last edited by
      #2

      I used a template column and added all of the possible controls. Currently 2 textboxes and 3 dropdowns. To display them you will have to set the visible property in the ItemDataBound event of the grid. You will also have to determine from existing values in the current row in the ItemDataBound event what to display or hide. I have an addition hidden textbox that tell what to display and what not to display.

      Private Sub Grid1_ItemDataBound(ByVal sender As System.Object, _
      ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
      Handles Grid1.ItemDataBound
      'Example
      Dim ctlDec As HtmlInputText
      Dim ctlDD As DropDownList

      ctlDec = e.Item.FindControl("txtResultDecimal")
      ctlDD = e.Item.FindControl("ddlResults")

      ctlDec.Visible = True
      ctlDD.Visible = False
      '...
      End Sub

      Not sure if this is the best way but it works. Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

      G 1 Reply Last reply
      0
      • G glad_to_be_here

        Hi : Anyone had experience displaying different items under:confused: same column ? for example, display image on column1, row 1; display dropdown on column1, row 2. I figured that template is not a good idea here. Am I right ? any suggesions ? Thanks!

        L Offline
        L Offline
        lupin68
        wrote on last edited by
        #3

        What are you trying to achieve? Datagrid is usually used as a list to display and edit data from a DB. Based on what your saying, you're probably better of building a Table dynamically and insert whatever dontrols you want wherever you want. Then again it all depends on what you want to do. P.

        D 1 Reply Last reply
        0
        • L lupin68

          What are you trying to achieve? Datagrid is usually used as a list to display and edit data from a DB. Based on what your saying, you're probably better of building a Table dynamically and insert whatever dontrols you want wherever you want. Then again it all depends on what you want to do. P.

          D Offline
          D Offline
          Dr_X
          wrote on last edited by
          #4

          Here is a picture of my grid. FYI: Clicking on the Specs button causes a postback and displays the prefix & suffix dropdowns. http://24.174.103.47/CustomDataGrid.jpg Is this similar to what you are looking for? Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

          G L 2 Replies Last reply
          0
          • D Dr_X

            I used a template column and added all of the possible controls. Currently 2 textboxes and 3 dropdowns. To display them you will have to set the visible property in the ItemDataBound event of the grid. You will also have to determine from existing values in the current row in the ItemDataBound event what to display or hide. I have an addition hidden textbox that tell what to display and what not to display.

            Private Sub Grid1_ItemDataBound(ByVal sender As System.Object, _
            ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
            Handles Grid1.ItemDataBound
            'Example
            Dim ctlDec As HtmlInputText
            Dim ctlDD As DropDownList

            ctlDec = e.Item.FindControl("txtResultDecimal")
            ctlDD = e.Item.FindControl("ddlResults")

            ctlDec.Visible = True
            ctlDD.Visible = False
            '...
            End Sub

            Not sure if this is the best way but it works. Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

            G Offline
            G Offline
            glad_to_be_here
            wrote on last edited by
            #5

            Thanks for the idea!

            1 Reply Last reply
            0
            • D Dr_X

              Here is a picture of my grid. FYI: Clicking on the Specs button causes a postback and displays the prefix & suffix dropdowns. http://24.174.103.47/CustomDataGrid.jpg Is this similar to what you are looking for? Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

              G Offline
              G Offline
              glad_to_be_here
              wrote on last edited by
              #6

              Thanks! My grid would be less complicated. I need to display a checkbox if the value from database is ture, display a dropdown if the value from database is false. I'll take the first suggestion, using visible property to true or false. It might be the easiest thing to do. Thanks for the help!

              D 1 Reply Last reply
              0
              • D Dr_X

                Here is a picture of my grid. FYI: Clicking on the Specs button causes a postback and displays the prefix & suffix dropdowns. http://24.174.103.47/CustomDataGrid.jpg Is this similar to what you are looking for? Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

                L Offline
                L Offline
                lupin68
                wrote on last edited by
                #7

                This looks like a Cool app Dr X. I'm just wondering about the DataGrid functionality in here. Is Column 1 static or is it something you're reading from a table? How many tables are involved? Just for personal info

                D 1 Reply Last reply
                0
                • L lupin68

                  This looks like a Cool app Dr X. I'm just wondering about the DataGrid functionality in here. Is Column 1 static or is it something you're reading from a table? How many tables are involved? Just for personal info

                  D Offline
                  D Offline
                  Dr_X
                  wrote on last edited by
                  #8

                  There is a header table and the grid is the details. Basically all rows are editable at the same time. The left column, Property Test, is a predefined list from in the database. Each Property Test can have 3 types of results: ResultDecimal, ResultText & ResultInteger. The ResultInteger value is basically for predefined DropDown lists. Currently it the only one list Pass/Fails which was further down in the grid and cut-off in the pic. To make it even more complex, the customer has different products and those products have various reports which only have certain Property Tests on them. In the end there are the following tables are all associated with displaying the results in the grid. tblSamplesSample - Header Record tblSamplesSampleResult - Grid, detail records tblSamplesProduct - All of the products tblSamplesProductPropertyTest - List of Products and Associateed tests tblSamplesCustomerProduct - List of customer products tblSamplesCustomerProductReport - Lists of customer reports per product tblSamplesCustomerProductRerportPropertyTest - List of prop.test per a cust. product report. tblSamplesResultType - ResultDecimal, ResultText, ResultInteger tblSamplesResultTypeList - List name for the drop down for ResultInteger tblSamplesResultTypeListItem - Item in the dropdown box per list name tblSamplesResultDetailSpecification - The prefix/suffix dropdown lists There are more tables associated to the data above but are used on an analysis page. The reason every table name has the prefix 'Samples' is because the web app is designed to hold multiple applications. And YES, this thing has turned into a booger. :eek: Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

                  1 Reply Last reply
                  0
                  • G glad_to_be_here

                    Thanks! My grid would be less complicated. I need to display a checkbox if the value from database is ture, display a dropdown if the value from database is false. I'll take the first suggestion, using visible property to true or false. It might be the easiest thing to do. Thanks for the help!

                    D Offline
                    D Offline
                    Dr_X
                    wrote on last edited by
                    #9

                    You will still need to return that value from the database in each row as a hidden value. In the ItemDatabound event, you will need to evaluate it by obtaining the control's value by using FindControl. Again, I am not sure this is the best way but it does work. If anyone else can add to this or come up with a better way please feel free to discuss it. Datagrid Girl is one of the grid experts on this site. Maybe she can add to it on Monday. Hope this gets you on the right track. Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

                    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