<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
CellSpacing
=
"0"
GridLines
=
"None"
PageSize
=
"25"
Skin
=
"Windows7"
Width
=
"100%"
AutoGenerateColumns
=
"False"
OnExcelMLExportStylesCreated
=
"RadGrid1_ExcelMLExportStylesCreated"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnInit
=
"RadGrid1_Init"
OnInsertCommand
=
"RadGrid1_ItemCommand"
>
<
ExportSettings
ExportOnlyData
=
"True"
OpenInNewWindow
=
"True"
FileName
=
"DataExport"
IgnorePaging
=
"True"
Excel-FileExtension
=
"xls"
Excel-Format
=
"ExcelML"
>
<
Excel
Format
=
"ExcelML"
></
Excel
>
</
ExportSettings
>
<
MasterTableView
IsFilterItemExpanded
=
"True"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"true"
ShowExportToExcelButton
=
"True"
ShowExportToCsvButton
=
"True"
AddNewRecordText
=
"Add"
/>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Active"
FilterControlAltText
=
"Filter Active column"
HeaderText
=
"Active"
FilterControlWidth
=
"65%"
UniqueName
=
"Active"
DataType
=
"System.Boolean"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = MyInfo.Get();
if (!Page.IsPostBack)
{
RadGrid1.MasterTableView.FilterExpression = "(Active = true)";
GridColumn col = RadGrid1.MasterTableView.GetColumnSafe("Active");
col.CurrentFilterFunction = GridKnownFunction.EqualTo;
col.CurrentFilterValue = "true";
}
}
Server Error in '/' Application.
No property or field 'Active' exists in type 'DataRowView'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
I have a grid where I'm binding data in the needdatasource event, and I'm retrieving a limited selection of records based on the page index. So when they go to the next page, I want to get the next batch of records based on the page size, and when they go back I want to get the previous batch, etc.
The problem I'm seeing is that the NeedDataSource event fires BEFORE the PageIndexChanged event. This means the CurrentPageIndex of the data grid in the NeedDataSource will always be incorrect, since it will always have the old value. I tried testing the RebindReason of the grid to see if I could determine if a page event had caused it, but that always returns ExplicitRebind {4} so it is useless.
How do I figure out what the correct page index is in the NeedDataSource event?
Error de servidor en la aplicación '/SCNUARP'.
--------------------------------------------------------------------------------
Referencia a objeto no establecida como instancia de un objeto.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.
Detalles de la excepción: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.
Error de código fuente:
Se ha generado una excepción no controlada durante la ejecución de la solicitud Web actual. La información sobre el origen y la ubicación de la excepción pueden identificarse utilizando la excepción del seguimiento de la pila siguiente.
Seguimiento de la pila:
[NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.]
Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +2186
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +268
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +102
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderPage(HtmlTextWriter nullWriter, Control page) +179
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +268
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1386
--------------------------------------------------------------------------------
Información de versión: Versión de Microsoft .NET Framework:4.0.30319; Versión ASP.NET:4.0.30319.18055
Protected
Sub
BTExportar_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
BTExportar.Click
If
Hoja.Items.Count > 0
Then
Hoja.ExportSettings.ExportOnlyData =
True
Hoja.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML
Hoja.MasterTableView.ExportToExcel()
End
If
End
Sub
Dim
Tabla
As
New
DataTable
Tabla.Columns.Add(
"CVE"
)
Tabla.Columns.Add(
"seccion"
)
Tabla.Columns.Add(
"indicador"
)
Tabla.Columns.Add(
"criterio"
)
Tabla.Columns.Add(
"si"
)
Tabla.Columns.Add(
"no"
)
Tabla.Columns.Add(
"na"
)
Tabla.Columns.Add(
"avance"
)
Tabla.Columns.Add(
"accion"
)
Tabla.Columns.Add(
"responsable"
)
Fila(0) =
"Clave"
Fila(1) = Seccion
Fila(2) =
""
Fila(3) =
""
Fila(4) =
""
.
.etc.
Tabla.Rows.Add(Fila)
Hoja.DataSource = Tabla
Hoja.DataBind()
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1" %>
<!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
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadSkinManager
ID
=
"QsfSkinManager"
runat
=
"server"
ShowChooser
=
"true"
/>
<
telerik:RadFormDecorator
ID
=
"QsfFromDecorator"
runat
=
"server"
DecoratedControls
=
"All"
EnableRoundedCorners
=
"false"
/>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
telerik:RadTreeList
ID
=
"RadTreeList1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
ParentDataKeyNames
=
"REPORTS_TO"
DataKeyNames
=
"EMP_ID"
AutoGenerateColumns
=
"False"
Width
=
"617px"
>
<
Columns
>
<
telerik:TreeListBoundColumn
DataField
=
"EMP_ID"
UniqueName
=
"EMP_ID"
HeaderText
=
"EMP_ID"
></
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
DataField
=
"REPORTS_TO"
UniqueName
=
"REPORTS_TO"
HeaderText
=
"REPORTS_TO"
></
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
DataField
=
"SALES"
UniqueName
=
"SALES"
HeaderText
=
"SALES"
></
telerik:TreeListBoundColumn
>
</
Columns
>
</
telerik:RadTreeList
>
</
telerik:RadAjaxPanel
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT "EMP_ID", "REPORTS_TO", "SALES" FROM "TREE_LIST_TEST""
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"></
asp:SqlDataSource
>
</
div
>
</
form
>
</
body
>
</
html
>