Matt Tapia
Top achievements
Rank 1
Matt Tapia
asked on 21 Jun 2010, 05:55 PM
Is there a way to fire a server-side event based on a row select of a rad-grid? Basically, I want to take a column value (that is the key value for the dataset) and use that to re-direct the page to a different page to view more information based on that key value. Right now, I can select a row, and then have a button that does the same thing based on the selected row, but I want to eliminate a click. Also, is there any way to make it only fire on a double-click event?
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 22 Jun 2010, 04:49 AM
Hello,
The ItemCommand event of grid fires when you select the row. You can access the row values as shown below.
C#:
The KB Article shows how to perform postback when double-clicking the row.
Performing postback from grid client events
-Shinu.
The ItemCommand event of grid fires when you select the row. You can access the row values as shown below.
C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Select") |
{ |
GridDataItem item = (GridDataItem)e.Item; |
Label1.Text = item["CompanyName"].Text; |
} |
} |
The KB Article shows how to perform postback when double-clicking the row.
Performing postback from grid client events
-Shinu.
0
Matt Tapia
Top achievements
Rank 1
answered on 22 Jun 2010, 01:34 PM
I tried the onItemCommand, but nothing happened...anything I need to change with my datagrid properties?
C#
<telerik:RadAjaxPanel runat="server"> |
<telerik:RadGrid runat="server" ID="rgAssignedClaims" Skin="WebBlue" |
AllowPaging="true" AllowSorting="true" PageSize="10" |
AllowFilteringByColumn="true" |
onitemcommand="rgAssignedClaims_ItemCommand" > |
<ClientSettings> |
<Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> |
</ClientSettings> |
<MasterTableView DataKeyNames="ClaimReviewID" TableLayout="Fixed" AutoGenerateColumns="false" > |
<Columns> |
<telerik:GridBoundColumn DataField="ClaimReviewID" HeaderText="Claim Review ID" AllowFiltering="false" /> |
<telerik:GridBoundColumn DataField="OrderID" HeaderText="Order ID" AllowFiltering="false" /> |
<telerik:GridBoundColumn DataField="PatientID" HeaderText="Patient ID" AllowFiltering="false" /> |
<telerik:GridBoundColumn DataField="LastName" HeaderText="Patient Name" AllowFiltering="false" /> |
<telerik:GridBoundColumn DataField="ClaimReviewStatusDescription" HeaderText="Status" AutoPostBackOnFilter="false" /> |
<telerik:GridBoundColumn DataField="CreateDate" HeaderText="DOS Date" AllowFiltering="false" /> |
</Columns> |
</MasterTableView> |
<PagerStyle Mode="NextPrevAndNumeric" /> |
</telerik:RadGrid> |
</telerik:RadAjaxPanel> |
<asp:Label ID="lblTest" runat="server" Text="xx"></asp:Label> |
C#
protected void rgAssignedClaims_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Select") |
{ |
GridDataItem item = (GridDataItem)e.Item; |
lblTest.Text = item["ClaimReviewID"].Text; |
} |
} |
0
Shinu
Top achievements
Rank 2
answered on 22 Jun 2010, 02:31 PM
Hello Matt,
I guess following approach is suitable for you.
aspx:
cs:
[I thought you were using GridButtonColumn with CommandName "Select". Thank you for giving complete code]
Regards,
Shinu.
I guess following approach is suitable for you.
aspx:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="rgAssignedClaims"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="rgAssignedClaims" /> |
<telerik:AjaxUpdatedControl ControlID="lblTest" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
<telerik:RadGrid runat="server" ID="rgAssignedClaims" Skin="WebBlue" |
AllowPaging="true" AllowSorting="true" PageSize="10" |
AllowFilteringByColumn="true" |
onitemcommand="rgAssignedClaims_ItemCommand" > |
<ClientSettings EnablePostBackOnRowClick="true"> |
<Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> |
</ClientSettings> |
<MasterTableView DataKeyNames="ClaimReviewID" TableLayout="Fixed" AutoGenerateColumns="false" > |
<Columns> |
. . . |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:Label ID="lblTest" runat="server" Text="xx"></asp:Label> |
cs:
protected void rgAssignedClaims_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Select") |
{ |
GridDataItem item = (GridDataItem)e.Item; |
lblTest.Text = item["ClaimReviewID"].Text; |
} |
} |
[I thought you were using GridButtonColumn with CommandName "Select". Thank you for giving complete code]
Regards,
Shinu.
0
Matt Tapia
Top achievements
Rank 1
answered on 02 Jul 2010, 04:19 PM
thanks. it took me a bit on the double-click since it was a control within a page, but this solution worked.