This is a migrated thread and some comments may be shown as answers.

[Solved] Grid row click showing value in asp:label

3 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 11 Aug 2013, 02:55 AM
I have a grid that has a row click event on it.  This event works and I see the breakpoint hit in the serverside code.

With the row value I pull, I can hit a database and get the result I am looking for and assign it to an asp:label control.  

The problem is, I never see that value on the screen in the label.  I have verified the label.text property has the value I want, however I can't get it to show on the screen.

Is there a command I need to fire to refresh the page after the grid is done with the serverside control?

I can provide code snippets if needed.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2013, 09:44 AM
Hello,

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="RadGrid1">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                       <telerik:AjaxUpdatedControl ControlID="Label1" LoadingPanelID="RadAjaxLoadingPanel1" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>
       <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
       </telerik:RadAjaxLoadingPanel>
       <telerik:RadGrid ID="RadGrid1">
       </telerik:RadGrid>
       <asp:Label ID="Label1"></asp:Label>

OR

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
       </telerik:RadAjaxManager>
       <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
       </telerik:RadAjaxLoadingPanel>
       <telerik:RadAjaxPanel>
           <telerik:RadGrid ID="RadGrid1">
           </telerik:RadGrid>
           <asp:Label ID="Label1"></asp:Label>
       </telerik:RadAjaxPanel>

OR
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Panel1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <asp:Panel ID="Panel1">
            <telerik:RadGrid ID="RadGrid1">
            </telerik:RadGrid>
            <asp:Label ID="Label1"></asp:Label>
        </asp:Panel>

OR

<asp:UpdatePanel>
          <ContentTemplate>
              <telerik:RadGrid ID="RadGrid1">
              </telerik:RadGrid>
              <asp:Label ID="Label1"></asp:Label>
          </ContentTemplate>
      </asp:UpdatePanel>


Thanks,
Jayesh Goyani
0
Princy
Top achievements
Rank 2
answered on 12 Aug 2013, 10:04 AM
Hi Jeff,

Please try the below code sample snippet.It shows the server side row-click event,and its event OnSelectedIndexChanged,you can access the label here.If this doesn't help,please provide your code.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnSelectedIndexChanged="Selection_Changed">
    <MasterTableView DataKeyNames="OrderID" >
        <Columns>
         <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />           
        </Columns>
    </MasterTableView>
    <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">
    </ClientSettings>
</telerik:RadGrid>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

C#:
protected void Selection_Changed(object sender, EventArgs e)
  {
    GridDataItem selectedItem = (GridDataItem)RadGrid1.SelectedItems[0];
    string key = selectedItem.GetDataKeyValue("OrderID").ToString(); // Getting selected rows dataKeyvalue
    Label1.Text = key;
  }

Thanks,
Princy
0
Jeff
Top achievements
Rank 1
answered on 12 Aug 2013, 03:51 PM
Thank you Jayesh!

I went with your second suggestion and put the entire setup in the asp:panel and it works like I had hoped!

I appreciate your help
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Share this question
or