<telerik:RadGrid ID="TransferItemsRadGrid" runat="server" AllowPaging="true" AllowSorting="true"
PageSize="10" AutoGenerateColumns="false" Skin="WebBlue" OnItemDataBound="TransferItemsRadGrid_ItemDataBound"
OnNeedDataSource="TransferItemsRadGrid_NeedDataSource">
<ClientSettings EnableRowHoverStyle="true" />
<GroupingSettings CaseSensitive="false" />
<ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true" />
<MasterTableView DataKeyNames="WORKORDERNUMBER,LOCATIONID,WORKORDERID,WORKORDERDETAILID,MATERIALTYPEID,MATERIALDESCRIPTION,INVENTORYID,ITYPE"
CommandItemDisplay="TopAndBottom" CommandItemStyle-HorizontalAlign="Left">
<PagerStyle Mode="NextPrevNumericAndAdvanced" />
<CommandItemSettings ShowExportToExcelButton="true" ExportToExcelText="Export to Excel"
ShowAddNewRecordButton="false" />
<NoRecordsTemplate>
<div style="text-align: center; margin: 20px;">
There are no transfer items associated with this work order.
</div>
</NoRecordsTemplate>
<HeaderStyle HorizontalAlign="Left" />
<Columns>
<telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="60px" UniqueName="OptionsMenuCell"
ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Image ID="RecordInfoImage" runat="server" ImageUrl="~/App_Themes/GOLD Main/Images/grid_info.gif"
CssClass="gridviewOptionsImage" />
<telerik:RadToolTip ID="InfoRadToolTip" runat="server" TargetControlID="RecordInfoImage"
Skin="Sunset" Position="MiddleRight" CssClass="gridviewToolTip" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="WORKORDERITEMDISPLAY" HeaderText="WO Item #" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="ITYPE" HeaderText="Type" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="MATERIALTYPE" HeaderText="Material" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="STATUS_MESSAGE" HeaderText="Status" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="SIZEVALUE" HeaderText="Size" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="WEIGHTPERLENGTH" HeaderText="Weight" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="MATERIALGRADE" HeaderText="Grade" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="MATERIALTHREAD" HeaderText="Thread" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="MATERIALCOLORBAND" HeaderText="Color" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="MATERIALCOATING" HeaderText="Coating" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="MATERIALRANGE" HeaderText="Range" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="RACKNUMBER" HeaderText="Rack" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="ADJ_QTY" HeaderText="Inv Qty" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="ADJ_LENGTH" HeaderText="Length" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="OWNER_COMPANYNAME" HeaderText="Owner" AllowFiltering="false" />
<telerik:GridBoundColumn DataField="LOCATIONNAME" HeaderText="Division" AllowFiltering="false" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
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"