Hi,
In my page i am using two <updatepanel>. One of the <updatepanel> is having WHDG. On server side row selectionchagned event of it i want to update the value of label control which is inside Infragistics tab control in another <updatepanel>. Any help on this will appreciate.
Thanks,
Mits
Hello Mitesh,
In order to implement the functionality you described you have to set EnableAjax property of the grid to “false" and set Auto post back flag for Row Selection. Below is markup of grid and label in two different update panels.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" EnableAjax="false"AutoGenerateColumns="False" Width="627px" DataKeyFields="Cutomer Id" OnRowSelectionChanged="WebHierarchicalDataGrid1_RowSelectionChanged"><Columns><ig:BoundDataField DataFieldName="Cutomer Id" Key="Cutomer Id"><Header Text="Cutomer Id"></Header></ig:BoundDataField><ig:BoundDataField DataFieldName="Address" Key="Address"><Header Text="Address"></Header></ig:BoundDataField></Columns><Behaviors><ig:Selection RowSelectType="Single" Enabled="true" CellSelectType="Multiple" CellClickAction="Row"><AutoPostBackFlags RowSelectionChanged="True" /></ig:Selection></Behaviors></ig:WebDataGrid></ContentTemplate></asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"><ContentTemplate><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></ContentTemplate></asp:UpdatePanel>
Below lines of code updates label text based on the cell selected in current row:
protected void WebDataGrid1_RowSelectionChanged(object sender, Infragistics.Web.UI.GridControls.SelectedRowEventArgs e){if (e.CurrentSelectedRows != null){string seltext = e.CurrentSelectedRows[0].Items[0].Text;Label2.Text = seltext;}}
Hope this helps.
Hi Bhadresh,
Thanks for quick reply. The mentioned code is not working in below scenario.
- Expand any row and select a row from child grid. (This works)
- Now without collapsing a first row expand another row and select row from their child grid. This will give an error like index was out of range.
Also is there any way that we can get a datakey of selected row.
Please look into this.
I was able to see the behavior you described. I have modified the code I have provided in order to find if the current selected row count is greater than 0. The modified code below also shows how to get data key of the selected row and show it in label:
if (e.CurrentSelectedRows != null && e.CurrentSelectedRows.Count > 0){//string seltext = e.CurrentSelectedRows[0].Items[0].Text;Object[] selkey = e.CurrentSelectedRows[0].DataKey;Object selkey0 = selkey[0];Label2.Text = selkey0.ToString();}
To use some features i have to keep EnableAjax property to true. So is there any idea how to do the same thing with EnableAjax = true.