<
telerik:RadGrid
ID
=
"rgShip"
runat
=
"server"
AutoGenerateColumns
=
"false"
Skin
=
"Windows7"
AllowMultiRowSelection
=
"false"
OnNeedDataSource
=
"LoadMethods"
>
<
MasterTableView
DataKeyNames
=
"ship_meth_id"
>
<
Columns
>
<
telerik:GridButtonColumn
DataTextField
=
"ship_meth_desc"
CommandName
=
"Select"
ItemStyle-HorizontalAlign
=
"Left"
HeaderText
=
"Shipping Method"
UniqueName
=
"shipmethdesc"
></
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Protected
Sub
LoadMethods()
Try
Dim
ds
As
dataset
ds = DBSvc.GetDataset,
"sp_Ship_Meth_SEL"
)
Dim
dv
As
DataView
dv = ds.Tables(0).DefaultView
dv.Sort =
"ship_meth_desc"
rgShip.DataSource = dv
Protected
Sub
rgShip_ItemCommand(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
rgShip.ItemCommand
Try
If
e.CommandName =
"Select"
Then
Dim
dataItem
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
txtMethod.Text = dataItem(
"shipmethdesc"
).Text
Hello,
I would like to handle multiselection in RadGrid on server side, but not by storing the selected item during every selection/deselection like in the sample http://www.telerik.com/help/aspnet-ajax/grdpersistselectedrowsonsorting.html, but storing them only during sorting, paging, filtering and some custom commands. I have added a GridClientSelectColumn to my MasterTableView columns, so the graphical handling of the multiselection on one page works fine. But if I would like to get in the OnItemCommand handler of the grid(after paging, sorting or RadGrid.DeleteSelectedCommandName), whether the checkbox of a row(DataItem) is checked or not, I can not get this information. The returned states of the checkboxes are always false. Could you suggest a way, how can I get/set the selected state of a row in this case?
I don’t want to have callbacks by every (de)selection, although no EnablePostBackOnRowClick=true and RadGrid.SelectCommandName/RadGrid.DeselectCommandName or GridTemplateColumn with AutoPostBack=true. I could not solve the problem with GridTemplateColumn and AutoPostBack=false and another problem of this case, that the graphical part of the selection is not automatically solved.
Thanks:
Zoltán
My checkbox is in the third column. I get the state of the checkbox with the following:
bool selected = (dataItem.Cells[2].Controls[0] as CheckBox).Checked;
My RadGrid definition:
<telerik:RadGrid ID="RadGridFiltered" runat="server" Skin="WebBlue"
AllowSorting="true" AllowPaging="true" AllowMultiRowSelection="true" PageSize = 10
OnItemCommand="RadGridFiltered_OnItemCommand" OnPreRender="RadGridFiltered_PreRender">
<MasterTableView DataKeyNames="RETURN_ID" AutoGenerateColumns="true" CommandItemDisplay="Top" >
<CommandItemTemplate>
<div style="padding: 5px 5px;">
<asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGridFiltered.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Kijelölt módosítása</asp:LinkButton>
</div>
</CommandItemTemplate>
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="true" EnableDragToSelectRows="true" />
</ClientSettings>
</telerik:RadGrid>
My selection store handler:
public void RadGridFiltered_OnItemCommand(object sender, GridCommandEventArgs args)
{
StoreSelectedItems();
.........
}
const string SessionSelectedItems = "SelectedItems";
const string KeyName = "RETURN_ID";
protected void StoreSelectedItems()
{
ArrayList selectedItems = (Session[SessionSelectedItems] != null) ? (ArrayList)(Session[SessionSelectedItems]) : new ArrayList();
foreach (GridDataItem dataItem in RadGridFiltered.MasterTableView.Items)
{
bool selected = (dataItem.Cells[2].Controls[0] as CheckBox).Checked; // ALWAYS FALSE !!!
dataItem.Selected = selected;
string id = dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex][KeyName].ToString();
if (selected && !selectedItems.Contains(id))
selectedItems.Add(id);
else if (!selected && selectedItems.Contains(id))
selectedItems.Remove(id);
}
Session[SessionSelectedItems] = selectedItems;
}
class
CheckBoxTemplate : ITemplate
{
string
ColName =
"cboCol1"
;
const
string
head =
"<div onclick=\"StopPropagation(event)\">"
;
const
string
tail =
"</div>"
;
public
void
InstantiateIn(Control container)
{
CheckBox chkControl =
new
CheckBox();
chkControl.ID =
"chkControl"
;
chkControl.CssClass =
""
;
chkControl.Attributes.Add(
"onclick"
,
"onCheckBoxClick('"
+ _controlClientId +
"')"
);
chkControl.DataBinding +=
new
EventHandler(
this
.chkControl_DataBind);
container.Controls.Add(
new
LiteralControl(head));
container.Controls.Add(chkControl);
container.Controls.Add(
new
LiteralControl(tail));
}
public
void
chkControl_DataBind(Object sender, EventArgs e)
{
CheckBox chkControl = (CheckBox)sender;
RadComboBoxItem radComboItem = (RadComboBoxItem)chkControl.NamingContainer;
chkControl.Text =
" "
+ DataBinder.Eval(radComboItem.DataItem, ColName).ToString();
}
}
var
xmlDoc = xmlDoc.firstChild;
if
(xmlDoc.childNodes.length > 0) {
var
combo = $find(comboid);
combo.trackChanges();
for
(x = 0; x < xmlDoc.childNodes.length; x++) {
try
{
sCboID = xmlDoc.childNodes[x].childNodes[0].childNodes[0].nodeValue;
sCboText = xmlDoc.childNodes[x].childNodes[1].childNodes[0].nodeValue;
var
comboItem =
new
Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text(sCboText);
comboItem.set_value(sCboID);
combo.get_items().add(comboItem);
}
catch
(err) { }
}
combo.commitChanges();
}
I received an incomplete
project utilising Telerik controls after a coworker left our company.
After installing the latest version of Telerik, I loaded the project and
encountered a few initial errors with controls not rendering.
The project previously made use of Telerik:RadScriptManager which I had to
change to the asp:ScriptManager in order to get the project to render and
compile. I had it working until yesterday when Visual Studio '08 was no longer
able to supply File, Line, Column, or Project Information on code errors.
Additionally, ASP.NET error pages (YPODs) are also unable to supply data on errors
- only supplying the following:
Description: An error
occurred during the compilation of a resource required to service this request.
Please review the following specific error details and modify your source code
appropriately.
Compiler Error Message: CS0103: The name 'hfChangePWError' does not
exist in the current context
Source Error:
|
[No relevant source lines] |
Source File: Line: 0
Show Detailed Compiler Output:
c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE> "C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe" /t:library /utf8output /R:"C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\App_Web_ayecinuc.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\assembly\dl3\fe2998c9\008db4e2_e221cb01\Telerik.Web.Design.DLL" /R:"C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\assembly\dl3\79065178\009b1d22_837fcb01\Telerik.Web.UI.DLL" /R:"C:\Windows\assembly\GAC_MSIL\System.Design\2.0.0.0__b03f5f7f11d50a3a\System.Design.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.DirectoryServices.AccountManagement\3.5.0.0__b77a5c561934e089\System.DirectoryServices.AccountManagement.dll" /R:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.DirectoryServices\2.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\App_Code.jelbpzvr.dll" /R:"C:\Windows\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /out:"C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\App_Web_default.aspx.cdcab7d2.xdzlie0w.dll" /D:DEBUG /debug+ /optimize- /win32res:"C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\aenyhhjc.res" /w:4 /nowarn:1659;1699;1701 /warnaserror- "C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\App_Web_default.aspx.cdcab7d2.xdzlie0w.0.cs" "C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\App_Web_default.aspx.cdcab7d2.xdzlie0w.1.cs" "C:\Users\DevUser.Domain\AppData\Local\Temp\Temporary ASP.NET Files\MyProject\e358ee4f\f7483ef9\App_Web_default.aspx.cdcab7d2.xdzlie0w.2.cs"
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.4926 for Microsoft (R) .NET Framework version 3.5 Copyright (C) Microsoft Corporation. All rights reserved. c:\(Work Files)\Source\MYPROJECT\Default.aspx(25,55): error CS0103: The name 'hfChangePWError' does not exist in the current context |
_________________________________________________________________________________________________________________________
Here are the asp.net directives and assembly references from Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ MasterType virtualpath="~/MasterPage.master" %>
<!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>
<telerik:RadStyleSheetManager
id="RadStyleSheetManager1" runat="server" />
</head>
<body style="background-image:url('Images/StartPageBackground.png');
background-repeat: no-repeat">
<form id="form1"
runat="server">
<asp:ScriptManager ID="RadScriptManager1"
runat="server" >
<Scripts>
<%--Needed for
JavaScript IntelliSense in VS2010--%>
<%--For VS2008
replace RadScriptManager with ScriptManager--%>
<asp:ScriptReference Assembly="Telerik.Web.UI"
Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI"
Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI"
Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</asp:ScriptManager>
_________________________________________________________________________________________________________________________
Any help you can offer on this issue would be greatly appreciated, as I'm still
fairly new to the usage and nuances of Telerik controls.
Thank you.