Hello people!
I'm trying to follow your simple databind example from : http://www.telerik.com/help/aspnet-ajax/grid-simple-data-binding.html but i have a problem, when the page loads for the first my grind has data, but when i sort, filter or paging, the data disappears and my grind comes at blank.....I'm passing a IList as Datasource My code is :
I'm trying to follow your simple databind example from : http://www.telerik.com/help/aspnet-ajax/grid-simple-data-binding.html but i have a problem, when the page loads for the first my grind has data, but when i sort, filter or paging, the data disappears and my grind comes at blank.....I'm passing a IList as Datasource My code is :
namespace iConnect.InvoicesScaling.Views
{
public partial class InvoicesScalingDefault : Microsoft.Practices.CompositeWeb.Web.UI.Page, IInvoicesScale
{
private InvoicesScalePresenter _presenter;
public System.Collections.Generic.IList<
Data.SapDocuments
> SapDocuments
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
LoadData();
RadGrid1.DataBind();
}
this._presenter.OnViewLoaded();
//A cada acesso à pagina verifica quem é o user
//criar instancia da Info para aceder ao metodo que me vai buscar a lista de users ao AD
Info x = new Info("xxx", "xxx", "xxxxx,DC=xx,DC=xx");
//get da lista dos direct report em user,key=manager(xx)
Dictionary<
string
, string> networkUser = new Dictionary<
string
, string>();
networkUser = x.GetHierarchyTree("axxva3");
//MessageBox.Show(Page.User.Identity.Name);
////Popular dados na Radlist
//RadGrid1.DataSource = this.SapDocuments;
//RadGrid1.DataBind();
}
[CreateNew]
public InvoicesScalePresenter Presenter
{
set
{
this._presenter = value;
this._presenter.View = this;
}
}
private void LoadData()
{
////Popular dados na Radlist
RadGrid1.DataSource = this.SapDocuments;
}
protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
{
RadGrid1.CurrentPageIndex = e.NewPageIndex;
LoadData();
RadGrid1.DataBind();
}
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName("SequencialNumber").Visible = false; // hide column before export
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.DataSource = this.SapDocuments; // please set data source again.
RadGrid1.DataBind();
}
}
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
LoadData();
}
}
}
and my aspx file is:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
asp:Content
ID
=
"content"
ContentPlaceHolderID
=
"DefaultContent"
runat
=
"Server"
>
<
script
src
=
"../Shared/js/jquery-1.6.2.min.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"../Shared/js/jquery.tooltip.js"
type
=
"text/javascript"
></
script
>
<
script
type
=
"text/javascript"
src
=
"../Silverlight.js"
></
script
>
<
style
type
=
"text/css"
>
.RadGrid_Black .rgFilterBox
{
background-color: #454545 !important;
}
</
style
>
<
h1
style
=
"text-align: center;"
>
Invoices Scale</
h1
>
<
br
/>
<
div
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
ViewStateMode
=
"Enabled"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"97%"
enableajax
=
"True"
CssClass
=
"productsGrid"
CellSpacing
=
"0"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
AllowMultiRowSelection
=
"True"
onitemcommand
=
"RadGrid1_ItemCommand"
onpageindexchanged
=
"RadGrid1_PageIndexChanged"
onneeddatasource
=
"RadGrid1_NeedDataSource"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
GridLines
=
"None"
ViewStateMode
=
"Enabled"
Width
=
"100%"
EnableColumnsViewState
=
"true"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SequencialNumber"
HeaderText
=
"SequencialNumber"
UniqueName
=
"SequencialNumber"
SortExpression
=
"SequencialNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Process"
HeaderText
=
"Staging"
UniqueName
=
"Process"
SortExpression
=
"Process"
FilterControlAltText
=
"Filter Process column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SupplierCode"
HeaderText
=
"SupplierCode"
UniqueName
=
"SupplierCode"
SortExpression
=
"SupplierCode"
FilterControlAltText
=
"Filter SupplierCode column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MessageStatus"
HeaderText
=
"MessageStatus"
UniqueName
=
"MessageStatus"
SortExpression
=
"MessageStatus"
FilterControlAltText
=
"Filter MessageStatus column"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DocumentType"
HeaderText
=
"DocumentType"
UniqueName
=
"DocumentType"
FilterControlAltText
=
"Filter DocumentType column"
SortExpression
=
"DocumentType"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
UniqueName
=
"InvoiceCreationDate"
DataField
=
"InvoiceCreationDate"
HeaderText
=
"InvoiceCreationDate"
FilterControlAltText
=
"Filter InvoiceCreationDate column"
SortExpression
=
"InvoiceCreationDate"
>
<
FilterTemplate
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker1"
runat
=
"server"
>
</
telerik:RadDatePicker
>
</
FilterTemplate
>
</
telerik:GridDateTimeColumn
>
<%--<
telerik:GridBoundColumn
DataField
=
"InvoiceCreationDate"
DataType
=
"InvoiceCreationDate"
FilterControlAltText
=
"Filter InvoiceCreationDate column"
HeaderText
=
"InvoiceCreationDate"
SortExpression
=
"InvoiceCreationDate"
UniqueName
=
"InvoiceCreationDate"
>
</
telerik:GridBoundColumn
>--%>
<
telerik:GridBoundColumn
DataField
=
"SupplierVatNumber"
FilterControlAltText
=
"Filter SupplierVatNumber column"
HeaderText
=
"SupplierVatNumber"
SortExpression
=
"SupplierVatNumber"
UniqueName
=
"SupplierVatNumber"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<%--<
EditFormSettings
ColumnNumber
=
"2"
CaptionFormatString
=
"Edit details for invoice with SequencialNumber {0}"
CaptionDataField
=
"SequencialNumber"
>
<
FormTableItemStyle
Wrap
=
"False"
></
FormTableItemStyle
>
<
FormCaptionStyle
CssClass
=
"EditFormHeader"
></
FormCaptionStyle
>
<
FormMainTableStyle
CellSpacing
=
"0"
CellPadding
=
"3"
Width
=
"100%"
/>
<
FormTableStyle
GridLines
=
"Horizontal"
CellSpacing
=
"0"
CellPadding
=
"2"
CssClass
=
"module"
Height
=
"110px"
Width
=
"100%"
/>
<
FormTableAlternatingItemStyle
Wrap
=
"False"
></
FormTableAlternatingItemStyle
>
<
FormStyle
Width
=
"100%"
BackColor
=
"#EEF2EA"
></
FormStyle
>
<
EditColumn
UpdateText
=
"Update record"
UniqueName
=
"EditCommandColumn1"
CancelText
=
"Cancel edit"
>
</
EditColumn
>
<
FormTableButtonRowStyle
HorizontalAlign
=
"Right"
CssClass
=
"EditFormButtonRow"
></
FormTableButtonRowStyle
>
</
EditFormSettings
>--%>
<
ExpandCollapseColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
RowIndicatorColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<%-- <
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EscalonamentoFacturasConnectionString %>"
SelectCommand="SELECT [SequencialNumber], [Priority],[Process], [SupplierCode], [MessageStatus], [DocumentType],[InvoiceCreationDate], [SupplierVatNumber] FROM [SapDocuments]
WHERE [Process] IN ('S','SP');"></
asp:SqlDataSource
>--%>
</
div
>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
<
br
/>
</
asp:Content
>