iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello, I have a hierarchical structure and each child row has a button that raises a postback event when I try to retrieve values in WebGrd1_ButtonClick with the code below I get an error because it can't retieve the object. Would be so kind to send me a sample to solve this problem. Thank you, luciano.
Dim SelObj As SelectedObject = WebGrid1.RetrieveClientLastSelectedObject()Dim SelInd As Integer
SelInd = SelObj.RowIndex
Dim TempVar = WebGrid1.RootTable.ChildTables(0).Rows(SelInd).Cells.GetNamedItem("NUMERO_PROTOCOLLO").Value
Hi Glenn, I have apreciate your effort to find a workaroud for something that isn't supported by WG. Considering that WG returns the entire composite key for the child selected row I prefer to retrieve it by querying the data adapter. I must say that I'm very disappoited because I am waiting since WG release 3.5 for a real composite key management. In any way, I must tank you for helping me. My best regards. Luciano
Hi Glenn, I have apreciate your effort to find a workaroud for something that isn't supported by WG. Considering that WG returns the entire composite key for the child selected row I prefer to retrieve it by querying the data adapter.
I must say that I'm very disappoited because I am waiting since WG release 3.5 for a real composite key management.
In any way, I must tank you for helping me.
My best regards.
Luciano
For hierarchical scenario, you will need to expand the parent row first in order to retrieve the child row cell information. Attached is a simple sample of hierarchical scenario that will alert the selected child row key value using server side button click.
Hi Glenn, I changed the code under WebGrid1_ButtonClick to bring it in mi scenario but it doesn't work. It doesn't return any key with:
Dim SelKey As String = WebGrid1.RetrieveClientLastSelectedObject().KeyValue
even forcing the key the following instruction doesn't work and I can't retrieve the child row's values:
Dim Protoco = WebGrid1.GetTableByName("Pratiche").Rows.GetRowByKeyValue(SelKey).Cells.GetNamedItem("NUMERO_PROTOCOLLO").Value
I connect Datasets using IsDataSource I didn't use all the other code because all keys and relations are declared inside the dataset. I'd like to clarify that the button is in the child rows so the rows are already expanded, the user selects a child row. Moreover if I try to retrieve the IndexRow it returns the right value.
Thank you, regards.
In the attached sample, the button column is binded to the ParentKey column, the idea is to assign the value of the parent key to the buttom column so during button click the last selected object key value will be available.
Here is the snippet:
<ISWebGrid:WebGridColumn Name="btnColumn" DataMember="parentKey" ColumnType="Button" ButtonText="Postback!" ButtonAutoPostback="true" ButtonPostbackMode="OnTheFly"></ISWebGrid:WebGridColumn>
Hi Glenn, may be we are near to find the solution. As I wrote above the button is inside the chid row what I have to retrieve is a cell value, not the parent key, from the selected child row. If I wil assing to the button the chid's key value will I get it server side? Moreover, afterwards how will I be able to retrieve values from child row cells?
Hi Gelenn, I kept on trying and the problem is that "lastclientselectedobject" doesn't return the key or keys value for the parent or child row. I got the same problem with checked rows and it came from the IsDataSource I had to change to ObjectDataSouce to populate the arraylist. When you will send a sample you must consider that 99% of my tables have a composite key.
I wasted a lot of time trying to find the solution, please help me otherwise it will drive me banas.
Hi Glenn, with the code below I can retrieve the composite key from the child selected row without any temporary column. What I'd like to know is: HOW TO RETRIEVE THE DATA FROM THIS CHILD ROW! I can't get over how it can be so complicate. Thank you, regards. Luciano
Dim KeyList As ArrayList = WebGrid1.RetrieveClientLastSelectedObject().KeyValuesDim SelInd As String = KeyList(0).ToString
The snippet to retrieve the data in the childrow for a non composite parent row during button click is
WebGrid1.RootTable.Rows.GetRowByKeyValue(e.CellValue).ExpandChildRow(); string selectedKey = WebGrid1.RetrieveClientLastSelectedObject().KeyValue;
The idea here is we need to expand the parent row first in order to retrieve the child data. The e.CellValue is the value of the button column which in the attached sample is referring to the parentKey column. In other words, in your compsoite key situation, you will need to buffer the composite key parent in a column to be able to reference it if you wanted to expand the row.
Or you could use a simpler solution, by adding the property RestoreExpandedChildRows="true" in the WebGrid LayoutSettings property to ensure the child row will be expanded. Without this property, you will need to use the above technique to ensure the child row table is loaded.
Hi Glenn, I have attached the code from my test page and it doesn't work. I can retrieve correctly the child and the parent composite key but, how you can see it doesn't work. Would you be so kind to tell me what is wrong. Thank you, regards. Luciano
Based on the error message in the screenshot, the error is returned because the GetRowByKeyValue return null. My hunch is because the data type in the ArrayList and the KeyValues of the parent row does not match. Have you tried using the object of the ChildKey item without casting the item to String?
Or you could use the RestoreExpandedChildRows="true" property in the LayoutSetting so the child row will be expanded and you could retrieve the child row info using the ChildKey variable:
//Acquire the selected child row WebGrid1.GetTableByName("childTableName").Rows.GetRowByKeyValue(ChildKey) //Acquire the selected child parent row WebGrid1.GetTableByName("childTableName").Rows.GetRowByKeyValue(ChildKey).Parent
Hi Glenn, my composite keys have the following fields:
Composite ParentKey = FirstKeyField is String - SecondKeyField is numeric
Composite ChidKey = FirstKeyField is Numeric - SecondKF Is string - ThirdKF is String
What format shuld have ChildKey to pass it as parameter in the following code (String, or what else)?
WebGrid1.GetTableByName("childTableName").Rows.GetRowByKeyValue(ChildKey)
If you don't mind please send me a sample about how to retrieve a row parent or child using a composite Key
The snippet is for the WebGrid1_ButtonClick in the 4_Glenn.jpg attachment. In this case the ChildKey variable will be RetrieveClientLastSelectedObject KeyValues property.
For the snippet to work, you will also need to use the RestoreExpandedChildRows="true" property in the LayoutSetting
Hi Glenn, I followed your advice but it still doesn't work, see the attachment. Is this feature supported in WG 6.0 2008 SP2? Because at this point I don't know what to think. If you can, please send me a database containing two tables parent and child, both having a composite key, plus the page when you retrieve the selected child row row by RetrieveClientLastSelectedObject KeyValues property.
Hi Glenn, I could retrieve child row's values with the code below and using only one field as key but I couldn't when the key is composite by more fields. How shoud I declare a coposite key in WG?
Dim Protocollo As Integer = CInt(WebGrid1.RetrieveClientLastSelectedObject().KeyValue) Session("PROTOCOLLO") = Protocollo Session("CODICE_RICHIEDENTE") = WebGrid1.GetTableByName("Pratiche").Rows.GetRowByKeyValue(Protocollo).Cells.GetNamedItem("CODICE_RICHIEDENTE").Value
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname