display different item in the cell under same column
-
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!
-
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!
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 DropDownListctlDec = e.Item.FindControl("txtResultDecimal")
ctlDD = e.Item.FindControl("ddlResults")ctlDec.Visible = True
ctlDD.Visible = False
'...
End SubNot 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)
-
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!
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.
-
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.
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)
-
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 DropDownListctlDec = e.Item.FindControl("txtResultDecimal")
ctlDD = e.Item.FindControl("ddlResults")ctlDec.Visible = True
ctlDD.Visible = False
'...
End SubNot 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)
Thanks for the idea!
-
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)
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!
-
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)
-
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
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)
-
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!
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)