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

Help Radrid!!

4 Answers 210 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gennaro
Top achievements
Rank 1
Gennaro asked on 22 Sep 2008, 12:29 PM
Hi!!

I have created this example but me does not work the script because what mistake? you indicate to me l' error and what I must fix and if you put to me l' example without l' error that I commit.

Thanks

I attend a solution

<%

@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%

@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

<title></title>

<script type="text/javascript">

function SetFirstRowActive() {

alert(

"ee");

var grid = $find("RadGrid1.ClientID");

grid.set_activeRow(grid.MasterTableView.get_dataItems()[0].get_element());

}

</script>

</

head>

<

body onload="SetFirstRowActive">

<form id="form1" runat="server">

<div style="height: 114px">

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1"

GridLines="None">

<

MasterTableView AutoGenerateColumns="False" DataKeyNames="Id_Categoria"

DataSourceID="SqlDataSource1">

<

RowIndicatorColumn>

<

HeaderStyle Width="20px"></HeaderStyle>

</

RowIndicatorColumn>

<

ExpandCollapseColumn>

<

HeaderStyle Width="20px"></HeaderStyle>

</

ExpandCollapseColumn>

<Columns>

<telerik:GridBoundColumn DataField="Id_Categoria" DataType="System.Int32"

HeaderText="Id_Categoria" ReadOnly="True" SortExpression="Id_Categoria"

UniqueName="Id_Categoria">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Categoria" HeaderText="Categoria"

SortExpression="Categoria" UniqueName="Categoria">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="InizCat" HeaderText="InizCat"

SortExpression="InizCat" UniqueName="InizCat">

</telerik:GridBoundColumn>

</Columns>

</

MasterTableView>

<ClientSettings AllowKeyboardNavigation="true">

<Selecting AllowRowSelect="True" />

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

</ClientSettings>

<

FilterMenu EnableTheming="True">

<

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

</

FilterMenu>

</telerik:RadGrid>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="Data Source=WINXPSP2NET;Initial Catalog=Example;Persist Security Info=True"

ProviderName="System.Data.SqlClient"

SelectCommand="SELECT [Id_Categoria], [Categoria], [InizCat] FROM [Categoria_Libri]">

</asp:SqlDataSource>

</div>

</form>

</

body>

</

html>

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Sep 2008, 05:34 AM
Hi Gennaro,

In your above given code you are trying to access the Grid as:

var grid = $find("RadGrid1.ClientID"); 

Try accessing the Grid on the client as shown below:

 var grid = $find("<%= RadGrid1.ClientID %>"); 
 grid.set_activeRow(grid.MasterTableView.get_dataItems()[0].get_element()); 


Thanks
Shinu
0
Gennaro
Top achievements
Rank 1
answered on 23 Sep 2008, 08:06 AM
Hi Shinu,

I have tried as you have said but they give this error to me, I have tried in any case but it continues to give this error to me as I can resolve it? Thanks of your answers

Impossible to modify l' Controls entirety because the control contains code blocks
(that is <% ... %>).

Description: Exception not managed during l' execution of the demand running Web. For further information sull' error and on its point of origin in the code, to see l' analysis of the stack.

Details exception: System.Web.HttpException: Impossible to modify l' Controls entirety because the control contains code blocks (that is <% ... %>).

Error in the code source:

During l' execution of the demand running Web has been generated un' exception not managed. For information sull' origin and the position dell' exception, to see l' analysis of the stack dell' brought back exception of continuation.

Analysis of the stack:


[HttpException (0x80004005):the control contains code blocks (that is<% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8674071 
   Telerik.Web.SkinRegistrar.RegisterCssReference(Page _page, Control _control, String _url) +371

[HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.]
   Telerik.Web.SkinRegistrar.RegisterCssReference(Page _page, Control _control, String _url) +436
   Telerik.Web.SkinRegistrar.RegisterCssReferences(ISkinnableControl _control) +721
   Telerik.Web.UI.RadCompositeDataBoundControl.RegisterCssReferences() +101
   Telerik.Web.UI.RadCompositeDataBoundControl.OnPreRender(EventArgs e) +103
   Telerik.Web.UI.RadGrid.OnPreRender(EventArgs e) +50
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
 (that is <% ... %>).
0
Princy
Top achievements
Rank 2
answered on 23 Sep 2008, 10:47 AM
Hello Gennaro,

Verify that if you are accessing the grid in javascript, it is being placed either outside of the head tag, or the head tag does not have a runat="server" attribute.

Thanks
Princy.
0
CharlesM
Top achievements
Rank 1
answered on 29 Jan 2009, 04:17 PM
What is the syntax if the javascript is outside of the head? e.g. in a UserControl. How do you find the control you are looking for?
Tags
Grid
Asked by
Gennaro
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Gennaro
Top achievements
Rank 1
Princy
Top achievements
Rank 2
CharlesM
Top achievements
Rank 1
Share this question
or