11 Answers, 1 is accepted
Try the following code to set the selected value in RadTextBox.
aspx:
protected void grid_SelectedIndexChanged(object sender, EventArgs e){ foreach (GridDataItem item in grid.SelectedItems) { string value = item["UniqueName"].Text; RadTextBox txt = (RadTextBox)item.FindControl("RadTextBox1"); txt.Text = value; }}Thanks,
Princy.
Here is the code in VB.
VB:
Protected Sub grid_SelectedIndexChanged(sender As Object, e As EventArgs) For Each item As GridDataItem In grid.SelectedItems Dim value As String = item("UniqueName").Text Dim txt As RadTextBox = DirectCast(item.FindControl("RadTextBox1"), RadTextBox) txt.Text = value NextEnd SubThanks,
Princy.
function RowSelected(sender, args) { document.getElementById("<%= Label1.ClientID %>").innerHTML = "<b>CustomerID: </b>" + args.getDataKeyValue("IDOCURRENCIA") + "<br />" + "<b>CompanyName: </b>" + args.getDataKeyValue("FECHA"); }but i dont know how to apply it to the RadTextbox.
thanks a lot Princy
I just made few small changes to the code and works very well, annex, Annex functional code:
Protected Sub RadGrid1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged For Each item As GridDataItem In RadGrid1.SelectedItems Dim value As String = item("UniqueName").Text RadTextBox1.Text = value Next End SubThanks Princy, your support was invaluable.
Regards.
GridData Item is not getting for me in RadGrid.
Can anyone help me please
I suggest that we continue on the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/selecting-radgrid-row-and-displaying-values-in-textboxes.aspx
Regards,
Eyup
Telerik
Can you please elaborate on your specific scenario?
Generally, you can check this article for accessing grid cell values:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html
Regards,
Eyup
Telerik
I am doing the same. But i am not getting postback on Row click to access the cell items.
Below is the code snippet.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="False"
GroupPanelPosition="Top"
Height="255px" Width="1320px" OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged"
OnItemCommand="RadGrid1_ItemCommand" OnItemEvent="RadGrid1_ItemEvent">
<ClientSettings EnablePostBackOnRowClick="True">
<Scrolling AllowScroll="True" UseStaticHeaders="True"
SaveScrollPosition="true" FrozenColumnsCount="2">
</Scrolling>
</ClientSettings>
<MasterTableView AutoGenerateColumns="false" ShowFooter="True">
<Columns>
<telerik:GridHyperLinkColumn
DataTextField="abc" UniqueName="abc" HeaderText="abc">
<HeaderStyle CssClass="RadGridColumnHeader" HorizontalAlign="Center"
VerticalAlign="Middle" />
</telerik:GridHyperLinkColumn>
<telerik:GridButtonColumn DataTextField="def" HeaderText="def">
</telerik:GridButtonColumn>
<telerik:GridHyperLinkColumn DataTextField="ghi" HeaderText="ghi">
</telerik:GridHyperLinkColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>​
I can see that you've enabled the EnablePostBackOnRowClick property:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/making-postback-or-ajax-request-on-client-row-click
This should cause a page postback on every row click. Could you temporarily disable any AJAX on the page(RadAjaxPanels, RadAjaxManager, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script errors interfering.
You can also examine the RadGridGetAllSelectedItemsImproved.zip sample provided in the following post for a more advanced selection scenario:
http://www.telerik.com/support/code-library/get-selected-items-through-all-pages#1eTU8nr-GUG8zfGgOGbIcA
Hope this helps.
Regards,
Eyup
Telerik
