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

Error ind RadGrid : 'RowSelected' is undefined" or “'null' is null or not an object”

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shaji
Top achievements
Rank 1
shaji asked on 12 Jul 2010, 02:25 PM

I am using  “ Telerik.Web.UI.dll  2009.2.826.20” in my  desktopmodule of DNN site.  This desktop module has RadGrid  which allows user to filter Records based on criteria (Username, FirstName & LastName ) specified and user can select required record from grid display.  
I am getting error  "'RowSelected' is undefined"   or   'null' is null or not an object”    while filtering the records based on criteria.  These errors occur occasionally, not always.   It is working perfectly some times with out above said errors.

See the Code Below

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectUser.aspx.cs" Inherits="ACS.Buck.UK.Modules.UserManagement.DesktopModules_UserManagement_SelectUser" %>

 

<%

@ 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>Select Member</title>

 

 

<style type="text/css">

 

.FilterTable td{ font: normal 10px Arial, Verdana, Sans-serif; }

 

</style>

 

</

 

head>

 

<

 

body>

 

 

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

 

 

<div>

 

 

<asp:Label ID="lblError" runat="server"></asp:Label>

 

<

 

telerik:RadGrid ID="GridMember" runat="server" CssClass="RadGrid" AllowSorting="True" ShowFooter="True" AllowPaging="True" AllowFilteringByColumn="True" AutoGenerateColumns="False" GridLines="None" Skin="Outlook" Width="100%" BorderStyle="None" PageSize="4" GroupingEnabled="False" OnPreRender="GridMember_PreRender" OnNeedDataSource="GridMember_NeedDataSource" onpageindexchanged="GridMember_PageIndexChanged" onpagesizechanged="GridMember_PageSizeChanged">

 

<

 

MasterTableView CssClass="MasterTable" DataKeyNames="UserID,Username,FirstName,LastName" ClientDataKeyNames="Username" BorderColor="#999999" BorderWidth="0px" CellPadding="1" GridLines="Vertical" Width="100%">

 

 

<Columns>

 

 

<telerik:GridBoundColumn DataField="Username" HeaderText="User ID" UniqueName="UserID">

 

 

<HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"

 

 

Font-Underline="False" Wrap="True" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" UniqueName="LastName">

 

 

<HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"

 

 

Font-Underline="False" Wrap="True" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" UniqueName="FirstName">

 

 

<HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"

 

 

Font-Underline="False" Wrap="True" Width="220px" />

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

<ExpandCollapseColumn Visible="False">

 

 

<HeaderStyle Width="19px" />

 

 

</ExpandCollapseColumn>

 

 

<RowIndicatorColumn Visible="False">

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn>

 

 

</MasterTableView>

 

 

<HeaderStyle CssClass="GridHeader"></HeaderStyle>

 

 

<GroupHeaderItemStyle CssClass="GroupHeader"></GroupHeaderItemStyle>

 

 

<ItemStyle CssClass="GridRow" BorderStyle="None" BorderWidth="0px"></ItemStyle>

 

 

<AlternatingItemStyle CssClass="GridRow"></AlternatingItemStyle>

 

 

<FooterStyle CssClass="GridFooter"></FooterStyle>

 

 

<PagerStyle CssClass="GridPager" Mode="NextPrevNumericAndAdvanced"

 

 

AlwaysVisible="True"></PagerStyle>

 

 

<ClientSettings >

 

 

<Scrolling UseStaticHeaders="True" ScrollHeight="" SaveScrollPosition="False"></Scrolling>

 

 

<Selecting AllowRowSelect="True" EnableDragToSelectRows="true"/>

 

 

<ClientEvents OnRowSelected="RowSelected" />

 

 

</ClientSettings>

 

 

<GroupPanel>

 

 

<PanelItemsStyle CssClass="GroupPanelItems"></PanelItemsStyle>

 

 

<PanelStyle CssClass="GroupPanel"></PanelStyle>

 

 

</GroupPanel>

 

 

<SelectedItemStyle Font-Bold="True" BackColor="LightSteelBlue" />

 

 

<FilterMenu CssClass="FilterTable" EnableViewState="False" HoverBorderColor="LightGray" SelectColumnBackColor="DarkGray" TextColumnBackColor="WhiteSmoke"></FilterMenu>

 

</

 

telerik:RadGrid>

 

 

</div>

 

 

</form>

 

 

</

 

body>

 

<

 

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

 

 

<script type="text/javascript">

 

 

var selected_member = "";

 

 

var oWnd = GetRadWindow();

 

 

function GetRadWindow()

 

{

 

var oWindow = null;

 

 

if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog

 

 

else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)

 

 

 

return oWindow;

 

}

 

function CloseAndReload()

 

{

oWnd.BrowserWindow.document.forms[0].selected_member.value = selected_member;

oWnd.BrowserWindow.document.forms[0].submit();

oWnd.Close();

}

 

function MemberSelected(rowIndex){

 

CloseAndReload();

}

 

function RowSelected(sender, args)

 

{

selected_member = args.getDataKeyValue(

"Username");

 

CloseAndReload();

}

 

 

</script>

 

 

</telerik:RadCodeBlock>

 

</

 

html>

 


code behind

 

partial class DesktopModules_UserManagement_SelectUser : DotNetNuke.Framework.PageBase //System.Web.UI.Page

 

{

 

protected void Page_Load(object sender, EventArgs e)

 

{

Page.Title = GetLocaleString(

"SelectUserPageTitle");

 

GridMember.PageSize = 10;

GridMember.Columns[0].HeaderText = GetLocaleString(

"UserID_Label");

 

GridMember.Columns[1].HeaderText = GetLocaleString(

"LastName_Label");

 

GridMember.Columns[2].HeaderText = GetLocaleString(

"FirstName_Label");

 

GridMember.Columns[0].FilterImageToolTip = GetLocaleString(

"Filter_Label");

 

GridMember.Columns[1].FilterImageToolTip = GetLocaleString(

"Filter_Label");

 

GridMember.Columns[2].FilterImageToolTip = GetLocaleString(

"Filter_Label");

 

}

 

private string GetFilter(Telerik.Web.UI.GridColumn c, string cName)

 

{

 

//if (c.CurrentFilterValue == "") return "";

 

 

string fv = c.CurrentFilterValue.ToUpper(); // filter value

 

 

string f = "";

 

 

switch (c.CurrentFilterFunction)

 

{

 

case GridKnownFunction.Between:

 

f =

"";

 

 

break;

 

 

case GridKnownFunction.Contains:

 

f = cName +

" like '%" + fv + "%'";

 

 

break;

 

 

case GridKnownFunction.Custom:

 

f =

""; // ???

 

 

break;

 

 

case GridKnownFunction.DoesNotContain:

 

f = cName +

" not like '%" + fv + "%'";

 

 

break;

 

 

case GridKnownFunction.EndsWith:

 

f = cName +

" like '%" + fv + "'";

 

 

break;

 

 

case GridKnownFunction.EqualTo:

 

f = cName +

" = '" + fv + "'";

 

 

break;

 

 

case GridKnownFunction.GreaterThan:

 

f = cName +

" > '" + fv + "'";

 

 

break;

 

 

case GridKnownFunction.GreaterThanOrEqualTo:

 

f = cName +

" >= '" + fv + "'";

 

 

break;

 

 

case GridKnownFunction.IsEmpty:

 

f = cName +

" = ''";

 

 

break;

 

 

case GridKnownFunction.IsNull:

 

f = cName +

" is null";

 

 

break;

 

 

case GridKnownFunction.LessThan:

 

f = cName +

" < '" + fv + "'";

 

 

break;

 

 

case GridKnownFunction.LessThanOrEqualTo:

 

f = cName +

" <= '%" + fv + "%'";

 

 

break;

 

 

case GridKnownFunction.NoFilter:

 

f =

"";

 

 

break;

 

 

case GridKnownFunction.NotBetween:

 

f =

""; // ???

 

 

break;

 

 

case GridKnownFunction.NotEqualTo:

 

f = cName +

" <> '" + fv + "'";

 

 

break;

 

 

case GridKnownFunction.NotIsEmpty:

 

f = cName +

" <> ''";

 

 

break;

 

 

case GridKnownFunction.NotIsNull:

 

f = cName +

" is not null";

 

 

break;

 

 

case GridKnownFunction.StartsWith:

 

f = cName +

" like '" + fv + "%'";

 

 

break;

 

};

 

return f;

 

}

 

protected void GridMember_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

 

{

 

string f = "";

 

 

string userName = GetFilter(GridMember.Columns[0], "U.Username");

 

 

string firstName = GetFilter(GridMember.Columns[1], "U.LastName");

 

 

string lastName = GetFilter(GridMember.Columns[2], "U.FirstName");

 

 

if (userName != "") f = f + " AND " + userName;

 

 

if (firstName != "") f = f + " AND " + firstName;

 

 

if (lastName != "") f = f + " AND " + lastName;

 

ACS.Buck.UK.Modules.MemberShadow.

SqlDataProvider sqlDP = new ACS.Buck.UK.Modules.MemberShadow.SqlDataProvider();

 

 

DataTable dtUsers = new DataTable();

 

 

 

int UserID = (int) Session["UserID"];

 

DotNetNuke.Security.Roles.

RoleController obj = new RoleController();

 

 

string[] arrRoles = obj.GetRolesByUser(UserController.GetCurrentUserInfo().UserID, PortalSettings.PortalId);

 

 

if(arrRoles.Count()==0)

 

{

dtUsers = sqlDP.GetUsers(PortalSettings.PortalId, f);

GridMember.DataSource = dtUsers;

}

 

else

 

{

 

bool status = false;

 

 

foreach (string role in arrRoles)

 

{

 

if(Config.GetSetting("LimitedAdmin")==role)

 

{

status =

true;

 

}

}

 

if(status==true)

 

{

ACS.Buck.UK.Modules.UserManagement.

SqlDataProvider sqlDP1 = new ACS.Buck.UK.Modules.UserManagement.SqlDataProvider();

 

 

DataTable dtUser = sqlDP1.getUsersWithoutAdmin(PortalSettings.PortalId, f);

 

GridMember.DataSource = dtUser;

}

 

else

 

{

dtUsers = sqlDP.GetUsers(PortalSettings.PortalId, f);

GridMember.DataSource = dtUsers;

}

}

 

// GridMember.DataBind();

 

}

 

protected void Grid
Member_PreRender(
object sender, EventArgs e)

 

{

 

GridFilterMenu menu = GridMember.FilterMenu;

 

 

// format is important and should be "|1|2|3|...|n|"

 

 

string UnWantedMenuItems = "|GreaterThan|LessThan|GreaterThanOrEqualTo|LessThanOrEqualTo|Between|NotBetween|IsEmpty|NotIsEmpty|IsNull|NotIsNull|";

 

 

int index = 0;

 

 

while (index < menu.Items.Count)

 

{

 

if (UnWantedMenuItems.Contains("|" + menu.Items[index].Text + "|"))

 

{

menu.Items.RemoveAt(index);

}

 

else

 

{

menu.Items[index].Text = GetLocaleString(menu.Items[index].Text);

//menu.Items[index].Text + index;

 

index++;

}

}

}

 

protected void GridMember_PageIndexChanged(object source, GridPageChangedEventArgs e)

 

{

GridMember.CurrentPageIndex = e.NewPageIndex;

}

 

protected void GridMember_PageSizeChanged(object source, GridPageSizeChangedEventArgs e)

 

{

 

if(e.NewPageSize < 1) {

 

e.Canceled =

true;

 

}

else {

 

GridMember.CurrentPageIndex = 0;

}

}

}

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 15 Jul 2010, 01:02 PM
Hello Shaji,

Based on the supplied information, it is hard to determine what is causing the error.
Please open a formal support ticket and send us the problematic module demonstrating the issue.
We will examine it locally and get back to you with our findings..

Thank you in advance for the cooperation.

Regards,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
shaji
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or