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

RadGrid row Selected

1 Answer 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
luis
Top achievements
Rank 1
luis asked on 01 Oct 2012, 10:05 PM

Hello .. I hope someone can help. I have a RadGrid on a Web Form with master page... i need to select a row and capture selected row index in a Label, to use this javascript code:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function RowSelected(sender, args) {
            document.getElementById("<%= Label1.ClientID  %>").innerHTML = args.get_itemIndexHierarchical();            
        }
    </script>
  </telerik:RadCodeBlock>

At runtime, in the internet explorer, I can see that Label change to value of Row Selected ... for example: 2, 4, 7, 11 .
However, when I press a button the value of Labelxx.Text is ever "Label", the value really never change. I read many forums and posed a possible solution and that many people have worked is:


1) In the webform.aspx replace the code

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

by this

<asp:HiddenField ID="Label1" runat="server" />

2) replace the next line in javascript code:

document.getElementById("<%= Label1.ClientID  %>").innerHTML = args.get_itemIndexHierarchical();

by this

document.getElementById('Label1').value = args.get_itemIndexHierarchical();

3) in the Webform.aspx.cs take the value of label with:


string value_row = Label1.value


Curiosly .. this solucion works for me when the Webform.aspx isnot with the masterpage... When Webform.aspx is with MasterPage ... the same code is not working; I checked variables, codes, script and dont working ... nothing :'(

The MasterPage only contain a RadToolBar, a scriptManager and ContentPaceHolder... its all.
The WebForm only contain a RadGrid, native asp Label and native asp button...

 any idea why this happens? .. Thanks in advance for your help.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Oct 2012, 12:31 PM
Hello Luis,

Please note that when placed inside a Content Page, the controls client side IDs are getting modified.
Could you please try getting the Label as follows:
document.getElementById("<%= Label1.ClientID %>").textContent

I hope this will prove helpful. Please give it a try and let me know about the result.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
luis
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or