Hi
I have a 100000 record in my database. I want to bind this data in RadGrid as cluster. That’s mean I want to bind 10 records per page from code behind. And this time I want to filter using multiple columns in all records and want to bind 10 filtered records (per page) to RadGrid.
So that, I want to do search, filter and bind data (page by page) in RadGrid from code behind.
Please response any.
Aminul
<head runat="server">
<title></title>html, body, form
{
margin:0px;height:100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<telerik:RadSkinManager ID="RadSkinManager1" Runat="server">
</telerik:RadSkinManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadSplitter ID="RadSplitter1" Runat="server" Height="100%" Orientation="Horizontal" style="margin-top: 0px" Width="100%">
<telerik:RadPane ID="RadPane1" Runat="server" Height="52px" Scrolling="None">
<table border="0" cellpadding="0" cellspacing="0" style="border: 0px none #000000" width="100%">
<tr bgcolor="black">
<td align="right" width="100">
</td>
<td style="background-color: #C0C0C0" valign="bottom">
<asp:Label ID="lblDate" Runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="12px" ForeColor="Black">
</asp:Label>
</td>
<td align="right" style="background-color: #C0C0C0" valign="bottom">
<asp:Label ID="lblUser" Runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="12px" ForeColor="Black"></asp:Label>
<br />
<asp:HyperLink ID="LogHyper" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="9pt" Font-Underline="True" ForeColor="Black" NavigateUrl="~/Login.aspx" Target="_parent">LOGOUT</asp:HyperLink>
<br />
</td>
</tr>
</table>
</telerik:RadPane>
<telerik:RadPane ID="RadPane2" Runat="server" Height="525px">
<telerik:RadSplitter ID="RadSplitter2" Runat="server" Height="100%" Width="100%"></body>
[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.GridTemplateColumn.FillValues(IDictionary newValues, GridEditableItem editableItem) +435 Telerik.Web.UI.GridEditableItem.ExtractValues(IDictionary newValues) +164 Telerik.Web.UI.GridTableView.ExtractValuesFromItem(IDictionary newValues, GridEditableItem editedItem) +116 Telerik.Web.UI.GridTableView.PerformDelete(GridEditableItem editedItem, Boolean suppressRebind) +174 Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +4861 Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +191 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +137 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +111 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +176 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565My RadGrid code is listed below :
<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True" DataSourceID="UserDS" AllowSorting="True" AllowFilteringByColumn="True" AllowMultiRowEdit="True" Skin="Telerik" AutoGenerateColumns="False" ShowGroupPanel="True"> <PagerStyle Mode="NextPrevAndNumeric" /><HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu> <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="Id" DataSourceID="UserDS" HorizontalAlign="NotSet" EditMode="InPlace"><CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name" ColumnEditorID="GridTextBoxColumnName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Surname" HeaderText="Surname" SortExpression="Surname" UniqueName="Surname" ColumnEditorID="GridTextBoxColumnSurname"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="User_Name" HeaderText="Username" SortExpression="User_Name" UniqueName="User_Name" ColumnEditorID="GridTextBoxColumnUserName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Id_Number" HeaderText="Id Number" SortExpression="Id_Number" UniqueName="Id_Number" ColumnEditorID="GridTextBoxColumnIdNumber" DataType="System.Int32"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="Role_Id" DataSourceID="RoleDdDS" HeaderText="Role" ListTextField="Role" ListValueField="Id" UniqueName="Role_Id" ColumnEditorID="GridDropDownColumnEditor1"> </telerik:GridDropDownColumn> <telerik:GridTemplateColumn UniqueName="Password" AllowFiltering="false"> <EditItemTemplate> <telerik:RadTextBox ID="RadTextBox1" Runat="server" TextMode="Password"> </telerik:RadTextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidatorPassword" runat="server" ControlToValidate="RadTextBox1" Display="Static" Text="*" SetFocusOnError="True"></asp:RequiredFieldValidator> </EditItemTemplate> <HeaderTemplate> <asp:Label ID="Label1" runat="server" Text="Password"></asp:Label> </HeaderTemplate> </telerik:GridTemplateColumn> <telerik:GridButtonColumn ConfirmText="Delete this user" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> </telerik:GridButtonColumn> </Columns> <EditFormSettings ColumnNumber="2" CaptionDataField="User" CaptionFormatString="Edit properties of User {0}" InsertCaption="New User"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <EditColumn ButtonType="ImageButton" InsertText="Insert User" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowDragToGroup="True"> <ClientEvents OnRowDblClick="RowDblClick" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings> </telerik:RadGrid> </asp:Panel> <telerik:RadWindowManager ID="RadWindowManager1" runat="server"> <Windows> <telerik:RadWindow ID="RadWindow" runat="server" style="display:none;"> </telerik:RadWindow> </Windows> </telerik:RadWindowManager> <br /> <asp:SqlDataSource ID="UserDS" runat="server" ConnectionString="<%$ ConnectionStrings:sample_ConnectionString %>" ProviderName="System.Data.SqlClient" DeleteCommand="UPDATE [User] SET [Is_Deleted]=1 WHERE [Id]=@original_Id" InsertCommand="INSERT INTO [User] (User_Name, Name, Surname, Id_Number, Role_Id, Password) VALUES (@User_Name,@Name,@Surname,@Id_Number,@Role_Id,@Password)" SelectCommand="SELECT * FROM [User]" UpdateCommand="UPDATE [User] SET [User_Name] = @User_Name, [Name] = @Name, [Surname] = @Surname, [Id_Number] = @Id_Number, [Role_Id] = @Role_Id, [Password]=@Password WHERE [Id]=@original_Id" ConflictDetection="CompareAllValues" OldValuesParameterFormatString="original_{0}"> <DeleteParameters> <asp:Parameter Name="original_Id" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="User_Name" Type="String" /> <asp:Parameter Name="Name" Type="String" /> <asp:Parameter Name="Surname" Type="String" /> <asp:Parameter Name="Id_Number" Type="Int32" /> <asp:Parameter Name="Role_Id" Type="Int32" /> <asp:Parameter Name="Password" Type="String" /> <asp:Parameter Name="original_Id" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="User_Name" Type="String" /> <asp:Parameter Name="Name" Type="String" /> <asp:Parameter Name="Surname" Type="String" /> <asp:Parameter Name="Id_Number" Type="Int32" /> <asp:Parameter Name="Role_Id" Type="Int32" /> <asp:Parameter Name="Password" Type="String" /> </InsertParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="RoleDdDS" runat="server" ConnectionString="<%$ ConnectionStrings:sample_ConnectionString %>" SelectCommand="SELECT Id, Role FROM Role"></asp:SqlDataSource> <ContentTemplate>
<telerik:RadGrid ID="dgCompDetails" runat="server" AutoGenerateColumns="False" BorderStyle="Solid" CellSpacing="0" GridLines="None" Skin="Sitefinity">
<ClientSettings>
<Selecting CellSelectionMode="SingleCell" />
</ClientSettings>
<MasterTableView AllowNaturalSort="False" EditMode="InPlace" AllowAutomaticUpdates="True">
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
<PagerStyle PageSizeControlType="RadComboBox" />
</MasterTableView>
<PagerStyle PageSizeControlType="RadComboBox" />
<FilterMenu EnableImageSprites="False">
</FilterMenu>
</telerik:RadGrid>
</ContentTemplate>
'Code behind creation of columns
boundColumn = New GridBoundColumn()
dgCompDetails.MasterTableView.Columns.Add(boundColumn)
boundColumn.DataField = "ippComponentSrcValue"
boundColumn.UniqueName = "dgippComponentSrcValue"
boundColumn.Display = True
boundColumn.HeaderText = "Value"
RadFormDecorator does not decorate input type=button when class attribute is present.
Demo below.
Regards
<%@ Page Title="" Language="C#" MasterPageFile="~/TestUnit/TelerikBug/DecoratedButtonMaster.Master" AutoEventWireup="true" CodeBehind="DecoratedButton.aspx.cs" Inherits="TestUnit.TelerikBug.DecoratedButton" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> <script type="text/javascript" src="jquery-1.8.3.js"></script></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div id="addbuttonpanelid"> <input type="button" id="button20" value="bugdecoratedbutton" class="bug"/><br /> <input type="button" id="button1" value="decoratedbutton"/><br /> <input type="button" id="button5" disabled="disabled" value="decorateddisabledbutton" class="bug"/><br /> </div> <script type="text/javascript"> $(document).ready( function () { $("<br/>") .appendTo("#addbuttonpanelid"); $("<input type='button' id='button2' value='afterready'/>") .appendTo("#addbuttonpanelid"); $("#button1").click(function () { $('#button5').removeAttr('disabled'); $("<input type='button' id='button3' value='onclick'/>") .appendTo("#addbuttonpanelid"); $("<input type='button' id='button6' disabled='disabled' value='onclick'/>") .appendTo("#addbuttonpanelid"); $("<input type='button' id='button10id' name='voter' value='VOTER' class='bug'/>") .appendTo("#addbuttonpanelid"); var decorator = $find("RadFormDecoratorID"); if (decorator) { decorator.decorate(); } }); } ); </script></asp:Content>