本文介绍了Rad过滤器中的Rad过滤器无法使用Checkbox Colunm。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Trying to setup a grid view that I added a checkbox Colunm. Like the exampe here http://www.telerik.com/help/aspnet-ajax/grid-selecting-row-with-checkbox-server-side.html

The Checkbox works fine. The issue i am running it I am trying to add the rad filter to the to this grid. When I try to add expression i get This error. If I removeed the template check box colunm issue goes away and filter works. I also found this but am not sure what i need to do to fix my code. http://www.telerik.com/forums/radfilter-with-radgrid-fieldname-is-null

Server Error in '/' Application.

Parameter cannot be null or empty.

Parameter name: fieldName


Asp page code:

<%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" CodeFile="Default - Copy.aspx.cs" Inherits="_Default" %>

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



<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit.HTMLEditor" tagprefix="cc1" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>



<!DOCTYPE html>

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

<head runat="server">

<title></title>

</head>

<body>

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

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

</telerik:RadAjaxManager>

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

</asp:ScriptManager>

<telerik:RadFilter ID="RadFilter1" runat="server" DataSourceControlID="SqlDataSource1" FilterContainerID="RadGrid1" Skin="Windows7" AllowFilterOnBlur="True">

</telerik:RadFilter>

<div>





<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowFilteringByColumn="True" AllowMultiRowEdit="True" AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" Skin="Windows7">

<MasterTableView AutoGenerateColumns="False" DataKeyNames="SubListConID" DataSourceID="SqlDataSource1">

<Columns>



<telerik:GridTemplateColumn UniqueName="CheckBox1TemplateColumn" AndCurrentFilterFunction="Custom" AutoPostBackOnFilter="True" CurrentFilterFunction="Custom">

<ItemTemplate>

<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection"



AutoPostBack="True" />

</ItemTemplate>

<HeaderTemplate>

<asp:CheckBox ID="headerChkbox" runat="server" OnCheckedChanged="ToggleSelectedState"



AutoPostBack="True" />

</HeaderTemplate>

</telerik:GridTemplateColumn>





<telerik:GridBoundColumn DataField="SubListConID" DataType="System.Int32" FilterControlAltText="Filter SubListConID column" HeaderText="SubListConID" ReadOnly="True" SortExpression="SubListConID" UniqueName="SubListConID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="OldID" DataType="System.Int32" FilterControlAltText="Filter OldID column" HeaderText="OldID" SortExpression="OldID" UniqueName="OldID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="CompanyName" FilterControlAltText="Filter CompanyName column" HeaderText="CompanyName" SortExpression="CompanyName" UniqueName="CompanyName">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="AddressLine1" FilterControlAltText="Filter AddressLine1 column" HeaderText="AddressLine1" SortExpression="AddressLine1" UniqueName="AddressLine1">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="AddressLine2" FilterControlAltText="Filter AddressLine2 column" HeaderText="AddressLine2" SortExpression="AddressLine2" UniqueName="AddressLine2">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="City" FilterControlAltText="Filter City column" HeaderText="City" SortExpression="City" UniqueName="City">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="State" FilterControlAltText="Filter State column" HeaderText="State" SortExpression="State" UniqueName="State">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="ZIP" FilterControlAltText="Filter ZIP column" HeaderText="ZIP" SortExpression="ZIP" UniqueName="ZIP">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Phone" FilterControlAltText="Filter Phone column" HeaderText="Phone" SortExpression="Phone" UniqueName="Phone">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="PhoneExt" FilterControlAltText="Filter PhoneExt column" HeaderText="PhoneExt" SortExpression="PhoneExt" UniqueName="PhoneExt">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Phone2" FilterControlAltText="Filter Phone2 column" HeaderText="Phone2" SortExpression="Phone2" UniqueName="Phone2">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Phone2Ext" FilterControlAltText="Filter Phone2Ext column" HeaderText="Phone2Ext" SortExpression="Phone2Ext" UniqueName="Phone2Ext">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Fax" FilterControlAltText="Filter Fax column" HeaderText="Fax" SortExpression="Fax" UniqueName="Fax">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="CompanyEmail" FilterControlAltText="Filter CompanyEmail column" HeaderText="CompanyEmail" SortExpression="CompanyEmail" UniqueName="CompanyEmail">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="CompanyEmail2" FilterControlAltText="Filter CompanyEmail2 column" HeaderText="CompanyEmail2" SortExpression="CompanyEmail2" UniqueName="CompanyEmail2">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Website" FilterControlAltText="Filter Website column" HeaderText="Website" SortExpression="Website" UniqueName="Website">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="PrimaryContact_FirstName" FilterControlAltText="Filter PrimaryContact_FirstName column" HeaderText="PrimaryContact_FirstName" SortExpression="PrimaryContact_FirstName" UniqueName="PrimaryContact_FirstName">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="PrimaryContact_LastName" FilterControlAltText="Filter PrimaryContact_LastName column" HeaderText="PrimaryContact_LastName" SortExpression="PrimaryContact_LastName" UniqueName="PrimaryContact_LastName">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="PrimaryContact_Title" FilterControlAltText="Filter PrimaryContact_Title column" HeaderText="PrimaryContact_Title" SortExpression="PrimaryContact_Title" UniqueName="PrimaryContact_Title">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="PrimaryContact_Cell" FilterControlAltText="Filter PrimaryContact_Cell column" HeaderText="PrimaryContact_Cell" SortExpression="PrimaryContact_Cell" UniqueName="PrimaryContact_Cell">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="PrimaryContact_Email" FilterControlAltText="Filter PrimaryContact_Email column" HeaderText="PrimaryContact_Email" SortExpression="PrimaryContact_Email" UniqueName="PrimaryContact_Email">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SecondaryContact_FirstName" FilterControlAltText="Filter SecondaryContact_FirstName column" HeaderText="SecondaryContact_FirstName" SortExpression="SecondaryContact_FirstName" UniqueName="SecondaryContact_FirstName">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SecondaryContact_LastName" FilterControlAltText="Filter SecondaryContact_LastName column" HeaderText="SecondaryContact_LastName" SortExpression="SecondaryContact_LastName" UniqueName="SecondaryContact_LastName">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SecondaryContact_Title" FilterControlAltText="Filter SecondaryContact_Title column" HeaderText="SecondaryContact_Title" SortExpression="SecondaryContact_Title" UniqueName="SecondaryContact_Title">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SecondaryContact_Cell" FilterControlAltText="Filter SecondaryContact_Cell column" HeaderText="SecondaryContact_Cell" SortExpression="SecondaryContact_Cell" UniqueName="SecondaryContact_Cell">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="SecondaryContact_Email" FilterControlAltText="Filter SecondaryContact_Email column" HeaderText="SecondaryContact_Email" SortExpression="SecondaryContact_Email" UniqueName="SecondaryContact_Email">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="TradeID" DataType="System.Int32" FilterControlAltText="Filter TradeID column" HeaderText="TradeID" SortExpression="TradeID" UniqueName="TradeID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="TradeID_2" DataType="System.Int32" FilterControlAltText="Filter TradeID_2 column" HeaderText="TradeID_2" SortExpression="TradeID_2" UniqueName="TradeID_2">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="TradeID_3" DataType="System.Int32" FilterControlAltText="Filter TradeID_3 column" HeaderText="TradeID_3" SortExpression="TradeID_3" UniqueName="TradeID_3">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="TradeID_4" DataType="System.Int32" FilterControlAltText="Filter TradeID_4 column" HeaderText="TradeID_4" SortExpression="TradeID_4" UniqueName="TradeID_4">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="RangeTraveledID" DataType="System.Int32" FilterControlAltText="Filter RangeTraveledID column" HeaderText="RangeTraveledID" SortExpression="RangeTraveledID" UniqueName="RangeTraveledID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="UnionStatusID" DataType="System.Int32" FilterControlAltText="Filter UnionStatusID column" HeaderText="UnionStatusID" SortExpression="UnionStatusID" UniqueName="UnionStatusID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="DateAdded" DataType="System.DateTime" FilterControlAltText="Filter DateAdded column" HeaderText="DateAdded" SortExpression="DateAdded" UniqueName="DateAdded">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="DateLastModified" DataType="System.DateTime" FilterControlAltText="Filter DateLastModified column" HeaderText="DateLastModified" SortExpression="DateLastModified" UniqueName="DateLastModified">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="UserName" FilterControlAltText="Filter UserName column" HeaderText="UserName" SortExpression="UserName" UniqueName="UserName">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="BidID" DataType="System.Int32" FilterControlAltText="Filter BidID column" HeaderText="BidID" SortExpression="BidID" UniqueName="BidID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Trade1" FilterControlAltText="Filter Trade1 column" HeaderText="Trade1" SortExpression="Trade1" UniqueName="Trade1">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="UserID" DataType="System.Guid" FilterControlAltText="Filter UserID column" HeaderText="UserID" SortExpression="UserID" UniqueName="UserID">

<ColumnValidationSettings>

<ModelErrorMessage Text="" />

</ColumnValidationSettings>

</telerik:GridBoundColumn>

</Columns>

</MasterTableView>

<ClientSettings>

<Selecting AllowRowSelect="True" />

<ClientEvents OnGridCreated="GridCreated" OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />

</ClientSettings>

</telerik:RadGrid>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TDSDev3ConnectionString %>" SelectCommand="SELECT * FROM [subContractorList]"></asp:SqlDataSource>

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







<telerik:RadButton ID="RadButton1" runat="server" OnClick="RadButton1_Click" Skin="Windows7" Text="Email">

</telerik:RadButton>







<br />





</div>





</form>

</body>

</html>

Code behind

using System;



using System.Collections.Generic;



using System.Linq;



using System.Web;



using System.Web.UI;



using System.Web.UI.WebControls;



using Telerik.Web.UI;



using System.Data;



public partial class _Default : System.Web.UI.Page



{



protected void Page_Load(object sender, EventArgs e)



{



}



protected void EntityDataSource1_Selecting(object sender, EntityDataSourceSelectingEventArgs e)



{



}



protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)



{



if (e.Item.ItemType == GridItemType.Header)



{



GridHeaderItem headerItem = (GridHeaderItem)e.Item;



 CheckBox chkSelectAll = (CheckBox)headerItem["ClientSelectColumn"].Controls[0];



hf1.Value = chkSelectAll.ClientID;



}



}



protected void ToggleRowSelection(object sender, EventArgs e)



{



 ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;



bool checkHeader = true;



foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)



{



if (!(dataItem.FindControl("CheckBox1") as CheckBox).Checked)



{



 checkHeader = false;



break;



}



}



 GridHeaderItem headerItem = RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;



 (headerItem.FindControl("headerChkbox") as CheckBox).Checked = checkHeader;



}



protected void ToggleSelectedState(object sender, EventArgs e)



{



 CheckBox headerCheckBox = (sender as CheckBox);



foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)



{



 (dataItem.FindControl("CheckBox1") as CheckBox).Checked = headerCheckBox.Checked;



dataItem.Selected = headerCheckBox.Checked;



}



}



protected void RadButton1_Click(object sender, EventArgs e)



{



}



}

推荐答案


这篇关于Rad过滤器中的Rad过滤器无法使用Checkbox Colunm。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 14:58