user2673969
user2673969

Reputation: 1

Telerik Grid setting a standard ASP.NET label value

I have an RADgrid 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?

Upvotes: 0

Views: 474

Answers (1)

Jayesh Goyani
Jayesh Goyani

Reputation: 11154

Please try with the below code snippet.

ASPX

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="Label1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
    OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">
    </ClientSettings>
</telerik:RadGrid>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

ASPX.CS

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    dynamic data1 = new[] {
          new { ID = 1, Name ="Name_1"},
          new { ID = 2, Name = "Name_2"},
          new { ID = 3, Name = "Name_1"},
          new { ID = 4, Name = "Name_4"},
          new { ID = 5, Name = "Name_1"}
      };

    RadGrid1.DataSource = data1;
}


protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (RadGrid1.SelectedItems.Count > 0)
    {
        GridDataItem selectedItem = (GridDataItem)RadGrid1.SelectedItems[0];
        // Perform Your Logic here
        Label1.Text = DateTime.Now.ToString();
    }
}

For more information please check below link. http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-row-click-showing-value-in-asp-label.aspx

Upvotes: 1

Related Questions