Hello people,
I have a problem on my RadGrid1. two of the grid columns are navigation properties...The problem is when i enter on the page, all columns fields has data.But when i click to sort those two columns came without values..
I have already verify that the list i'm using as DataSource, has allways those two columns with values...The problem is that when i sort the Grid comes without values on "Priority" and "Process" fields.....
That's my code (ASPX.CS)
That's my ASPX Code:
I have a problem on my RadGrid1. two of the grid columns are navigation properties...The problem is when i enter on the page, all columns fields has data.But when i click to sort those two columns came without values..
I have already verify that the list i'm using as DataSource, has allways those two columns with values...The problem is that when i sort the Grid comes without values on "Priority" and "Process" fields.....
That's my code (ASPX.CS)
protected void Page_Load(object sender, EventArgs e)
{
ObjectResult<
SapDocuments
> objectSapDocs;
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowUnprocessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
}
this._presenter.OnViewLoaded();
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
}
else
{
RadGrid1.DataSource = null;
}
//RadGrid1.DataBind();
}
[CreateNew]
public InvoicesScalePresenter Presenter
{
set
{
this._presenter = value;
this._presenter.View = this;
}
}
protected void ShowProcessed_Click(object sender, EventArgs e)
{
ObjectResult<
SapDocuments
> objectSapDocs;
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowProcessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
}
else
{
RadGrid1.DataSource = null;
}
}
....
That's my ASPX Code:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"97%"
enableajax
=
"True"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnGridExporting
=
"RadGrid1_GridExporting"
AllowMultiRowSelection
=
"True"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"SequencialNumber"
Width
=
"100%"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SequencialNumber"
HeaderText
=
"SequencialNumber"
UniqueName
=
"SequencialNumber"
SortExpression
=
"SequencialNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Priorities.Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Staging.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
=
"SupplierVatNumber"
FilterControlAltText
=
"Filter SupplierVatNumber column"
HeaderText
=
"SupplierVatNumber"
SortExpression
=
"SupplierVatNumber"
UniqueName
=
"SupplierVatNumber"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
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
>
21 Answers, 1 is accepted
0
Ricardo
Top achievements
Rank 1
answered on 25 Aug 2011, 05:14 PM
When i sort or filter i get this exc:
System.NullReferenceException: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
0
Ricardo
Top achievements
Rank 1
answered on 25 Aug 2011, 06:39 PM
sorry i have already tried Priorities.Priority and Staging.Process, when i enter on the page, those columns has its values..but after a sort or a Filter...my RadGrid cames with both columns with null, when i'm sure that the list i'm using as DataSource has both columns with its values.........
<
MasterTableView
DataKeyNames
=
"SequencialNumber"
Width
=
"100%"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SequencialNumber"
HeaderText
=
"SequencialNumber"
UniqueName
=
"SequencialNumber"
SortExpression
=
"SequencialNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Priorities.Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priorities.Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Staging.Process"
HeaderText
=
"Staging"
UniqueName
=
"Process"
SortExpression
=
"Staging.Process"
FilterControlAltText
=
"Filter Process column"
>
</
telerik:GridBoundColumn
>
0
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Aug 2011, 07:54 PM
Hello,
Let me know in Template column you get value or not ?
Thanks,
Jayesh Goyani
<
telerik:GridBoundColumn
DataField
=
"Priorities.Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priorities.Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
// take one more (below) column for testing purpose
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
'<%# Eval("Priorities.Priority") %>'
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Let me know in Template column you get value or not ?
Thanks,
Jayesh Goyani
0
Ricardo
Top achievements
Rank 1
answered on 25 Aug 2011, 08:04 PM
Jayesh that's very urgent, can you be more specific please??
All I need is to add the ItemTemplate collumn after my GridBoundColumn
All I need is to add the ItemTemplate collumn after my GridBoundColumn
(Priorities.Priority) ??0
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Aug 2011, 08:08 PM
Hello,
Yes for testing purpose you have to add one itemtemplate in gridtemplatecolumn and check.
so we can identify its issue from Radgrid/data side.
Thanks,
Jayesh Goyani
Yes for testing purpose you have to add one itemtemplate in gridtemplatecolumn and check.
so we can identify its issue from Radgrid/data side.
Thanks,
Jayesh Goyani
0
Ricardo
Top achievements
Rank 1
answered on 25 Aug 2011, 08:15 PM
Jayesh at this moment i'm out of the office, but i can go there again in 30 minutes, because this is urgent, can you answer me in 45mnts?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Aug 2011, 08:02 AM
Hello,
Sorry before get your post i already leave / offline so not able give reply.
Let me know you are able to see value in ItemTemplate or not?
In addition : you take :
just for testing purpose create a new alias of
and assign this
let me know if any concern.
note : if possible then please attach your project.
Thanks,
Jayesh Goyani
Sorry before get your post i already leave / offline so not able give reply.
Let me know you are able to see value in ItemTemplate or not?
In addition : you take :
DataField
=
"Priorities.Priority"
just for testing purpose create a new alias of
Priorities.Priority
as NewPriority.and assign this
DataField
=
"NewPriority"
let me know if any concern.
note : if possible then please attach your project.
Thanks,
Jayesh Goyani
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 09:09 AM
Hello Jayesh can you please show me that in code??
Thank you
Thank you
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 09:14 AM
I add
And get an error on EVAL saying Preprocessor directive expected
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
'<% # Eval("Priorities.Priority") %>'
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
And get an error on EVAL saying Preprocessor directive expected
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 09:19 AM
I can't understand....
That's my code
That's my code
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"97%"
enableajax
=
"True"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnGridExporting
=
"RadGrid1_GridExporting"
AllowMultiRowSelection
=
"True"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"SequencialNumber"
Width
=
"100%"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SequencialNumber"
HeaderText
=
"SequencialNumber"
UniqueName
=
"SequencialNumber"
SortExpression
=
"SequencialNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Priorities.Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priorities.Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
'<% # Eval("Priorities.Priority") %>'
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"Staging.Process"
HeaderText
=
"Staging"
UniqueName
=
"Process"
SortExpression
=
"Staging.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
=
"SupplierVatNumber"
FilterControlAltText
=
"Filter SupplierVatNumber column"
HeaderText
=
"SupplierVatNumber"
SortExpression
=
"SupplierVatNumber"
UniqueName
=
"SupplierVatNumber"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
ExpandCollapseColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
ShowAddNewRecordButton
=
"False"
ShowExportToCsvButton
=
"True"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Aug 2011, 09:21 AM
Hello,
please check below link
http://weblogs.asp.net/rajbk/archive/2004/07/20/what-s-the-deal-with-databinder-eval-and-container-dataitem.aspx
Note : please create one sample website and put this page inside it. please send to me. so i can check where is the actual problem.
Thanks,
Jayesh Goyani
please check below link
http://weblogs.asp.net/rajbk/archive/2004/07/20/what-s-the-deal-with-databinder-eval-and-container-dataitem.aspx
Note : please create one sample website and put this page inside it. please send to me. so i can check where is the actual problem.
Thanks,
Jayesh Goyani
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 10:01 AM
Please Jayesh help me showing the changes on my code....I don't know what to try more :S
When I tried :
I get an error on Eval ("Preprocessor directive expected ");
when you said :
"In addition : you take :
just for testing purpose create a new alias of
and assign this
That's my last code (AT this moment The problem is when i sort or filter (Priority and Staging Columns sometimes cames with values, and sometimes cames blank....) Can it be a bug on the control?
When I tried :
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
'<% # Eval("Priorities.Priority") %>'
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
I get an error on Eval ("Preprocessor directive expected ");
when you said :
"In addition : you take :
DataField
=
"Priorities.Priority"
just for testing purpose create a new alias of
Priorities.Priority
as NewPriority.and assign this
DataField
=
"NewPriority"" -------> can you show me how can i made those changes on my ASPX ?
That's my last code (AT this moment The problem is when i sort or filter (Priority and Staging Columns sometimes cames with values, and sometimes cames blank....) Can it be a bug on the control?
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 10:27 AM
Hello Jayesh using itemTemplate (code bellow) i get this exception:
System.NullReferenceException: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"97%"
enableajax
=
"True"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
OnItemCommand
=
"RadGrid1_ItemCommand"
OnGridExporting
=
"RadGrid1_GridExporting"
AllowMultiRowSelection
=
"True"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"SequencialNumber"
Width
=
"100%"
CommandItemSettings-ShowExportToCsvButton
=
"True"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SequencialNumber"
HeaderText
=
"SequencialNumber"
UniqueName
=
"SequencialNumber"
SortExpression
=
"SequencialNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Priorities.Priority"
HeaderText
=
"Priority"
UniqueName
=
"Priority"
FilterControlAltText
=
"Filter Priority column"
SortExpression
=
"Priorities.Priority"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Priorities.Priority"
HeaderText
=
"NewPriority"
UniqueName
=
"NewPriority"
FilterControlAltText
=
"Filter NewPriority column"
SortExpression
=
"Priorities.Priority"
DataType
=
"System.Int32"
>
<
ItemTemplate
>
<%# Eval("Priorities.Priority") %>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"Staging.Process"
HeaderText
=
"Staging"
UniqueName
=
"Process"
SortExpression
=
"Staging.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
=
"SupplierVatNumber"
FilterControlAltText
=
"Filter SupplierVatNumber column"
HeaderText
=
"SupplierVatNumber"
SortExpression
=
"SupplierVatNumber"
UniqueName
=
"SupplierVatNumber"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
ExpandCollapseColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
ShowAddNewRecordButton
=
"False"
ShowExportToCsvButton
=
"True"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 10:40 AM
That's my last ASPX.CS code
public partial class InvoicesScalingDefault : iConnect.Web.iConnect, IInvoicesScale
{
private InvoicesScalePresenter _presenter;
//public System.Collections.Generic.IList<
Data.SapDocuments
> SapDocuments
//{
// get;
// set;
//}
protected void Page_Load(object sender, EventArgs e)
{
ObjectResult<
SapDocuments
> objectSapDocs;
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowUnprocessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
}
this._presenter.OnViewLoaded();
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
}
else
{
RadGrid1.DataSource = null;
}
}
[CreateNew]
public InvoicesScalePresenter Presenter
{
set
{
this._presenter = value;
this._presenter.View = this;
}
}
/// <
summary
>
/// No evento Click button seleciona facturas
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void RadButton1_Click(object sender, EventArgs e)
{
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
foreach (GridDataItem item in RadGrid1.Items)
{
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
if (item.Selected)
{
string seqNumber = item.GetDataKeyValue("SequencialNumber").ToString();
DateTime date = DateTime.Now;
try
{
objectContx.ExecuteStoreCommand("Insert INTO ProcessedInvoices values({0},{1},{2}) ", seqNumber, date, user);
}
catch (Exception)
{
string myStringVariable = "Factura já dada como processada";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
}
ObjectResult<
SapDocuments
> objectSapDocs;
objectSapDocs = objectContx.ShowUnprocessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var ite in objectSapDocs)
{
listSapDocuments.Add(ite);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
RadGrid1.DataBind();
}
else
{
RadGrid1.DataSource = null;
RadGrid1.DataBind();
}
//RadButton3.Text = "Processed :(" + (alreadyProceedcount - selectforunproceedcount).ToString() + ")" + " Unprocessed :(" + (totalCount - (alreadyProceedcount - selectforunproceedcount)).ToString() + ")";
}
}
}
/// <
summary
>
/// Evento que elimina facturas selecionadas
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void RadButton2_Click(object sender, EventArgs e)
{
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
foreach (GridDataItem item in RadGrid1.Items)
{
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
if (item.Selected)
{
string seqNumber = item.GetDataKeyValue("SequencialNumber").ToString();
try
{
objectContx.ExecuteStoreCommand("Delete from ProcessedInvoices Where SequencialNumber = {0} ",
seqNumber);
}
catch (Exception)
{
string myStringVariable = "Factura já dada como não processada";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
}
ObjectResult<
SapDocuments
> objectSapDocs;
objectSapDocs = objectContx.ShowProcessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var ite in objectSapDocs)
{
listSapDocuments.Add(ite);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
RadGrid1.DataBind();
}
else
{
RadGrid1.DataSource = null;
RadGrid1.DataBind();
}
}
}
}
/// <
summary
>
/// Export de todos os SequencialNumber da tabela para .csv
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
RadGrid1.MasterTableView.Columns.FindByUniqueName("SequencialNumber").Visible = true;
RadGrid1.ExportSettings.IgnorePaging = true;
int count = 0;
foreach (GridColumn column in RadGrid1.Columns)
{
if (column.Visible)
{
if (count > 0)
column.Visible = false;
else
count++;
}
}
}
}
/// <
summary
>
/// Método para formatar o sequencialNumber
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void RadGrid1_GridExporting(object sender, GridExportingArgs e)
{
e.ExportOutput = e.ExportOutput.Replace("\"\r\n\"", "\"\r\n\"'");
}
/// <
summary
>
///
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void ShowProcessed_Click(object sender, EventArgs e)
{
ObjectResult<
SapDocuments
> objectSapDocs;
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowProcessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
RadGrid1.DataBind();
}
else
{
RadGrid1.DataSource = null;
RadGrid1.DataBind();
}
}
/// <
summary
>
///
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void ShowUnProcessed_Click(object sender, EventArgs e)
{
//string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
//EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
//RadGrid1.DataSource = objectContx.ShowUnprocessedInvoices(user);
//RadGrid1.DataBind();
//ViewState["Data"] = objectContx.ShowUnprocessedInvoices(user);
ObjectResult<
SapDocuments
> objectSapDocs;
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowUnprocessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
RadGrid1.DataBind();
}
else
{
RadGrid1.DataSource = null;
RadGrid1.DataBind();
}
}
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 11:33 AM
Hello again it's very wired, because if My RadGrid brings 17000 rows, when i click to sort for example on column "MessageStatus" RadGrid make the sort and "Priority" and "Staging" comes with values....But if i click to sort on "Staging" column i get an exception "System.NullReferenceException: Object reference not set to an instance of an object" , if i click to sort on column Priority i get the same exception...
However if my RadGrid brings 3 or 5 rows, everything works fine.....
Could it be a bug on the control? My code is on the above posts...
However if my RadGrid brings 3 or 5 rows, everything works fine.....
Could it be a bug on the control? My code is on the above posts...
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Aug 2011, 12:49 PM
Hello,
sorry giving late reply because right now i am on job so i am not able to give enough time.
......
Not there is not such type of issue in Radgrid.
May be it was issue of ViewState so for testing purpose remove viewstate in your code and directly assign list to your grid's datasource.
like : Radgrid.DataSource =
Thanks,
Jayesh Goyani
sorry giving late reply because right now i am on job so i am not able to give enough time.
......
Not there is not such type of issue in Radgrid.
May be it was issue of ViewState so for testing purpose remove viewstate in your code and directly assign list to your grid's datasource.
like : Radgrid.DataSource =
listSapDocuments
;Thanks,
Jayesh Goyani
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 12:57 PM
Jayesh I can't because i'm using view state to handle wich of the two datasources my RadGrid needs to Bind....
:S
Can you help me?
:S
Can you help me?
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 01:05 PM
I'm using two lists to populate data on the RadGrid, so i needed to use the viewState because if you look into my code, you can see that i i'm using the viewState to handle wich "list" i want my RadGrid to Bind......
When I open the page i need to by default ,my RadGrid bind data from a list wich is feed by a method, but i have two buttons to change my RadGrid datasource....
So, i need to use the viewState to keep the last datasource binded to the RadGrid.....
When I open the page i need to by default ,my RadGrid bind data from a list wich is feed by a method, but i have two buttons to change my RadGrid datasource....
ShowProcessed_Click
,ShowUnProcessed_ClickSo, i need to use the viewState to keep the last datasource binded to the RadGrid.....
0
Ricardo
Top achievements
Rank 1
answered on 26 Aug 2011, 01:19 PM
can you tell how can i handle it without viewState?
protected void Page_Load(object sender, EventArgs e)
{
ObjectResult<
SapDocuments
> objectSapDocs;
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowUnprocessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
}
this._presenter.OnViewLoaded();
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
}
else
{
RadGrid1.DataSource = null;
}
}
protected void ShowProcessed_Click(object sender, EventArgs e)
{
ObjectResult<
SapDocuments
> objectSapDocs;
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowProcessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
RadGrid1.DataBind();
}
else
{
RadGrid1.DataSource = null;
RadGrid1.DataBind();
}
}
/// <
summary
>
///
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void ShowUnProcessed_Click(object sender, EventArgs e)
{
//string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
//EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
//RadGrid1.DataSource = objectContx.ShowUnprocessedInvoices(user);
//RadGrid1.DataBind();
//ViewState["Data"] = objectContx.ShowUnprocessedInvoices(user);
ObjectResult<
SapDocuments
> objectSapDocs;
string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1);
EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities();
objectSapDocs = objectContx.ShowUnprocessedInvoices(user);
List<
SapDocuments
> listSapDocuments = new List<
SapDocuments
>();
foreach (var item in objectSapDocs)
{
listSapDocuments.Add(item);
}
ViewState["Data"] = listSapDocuments;
if (ViewState["Data"] != null)
{
RadGrid1.DataSource = (List<
SapDocuments
>)ViewState["Data"];
RadGrid1.DataBind();
}
else
{
RadGrid1.DataSource = null;
RadGrid1.DataBind();
}
}
0
Ricardo
Top achievements
Rank 1
answered on 29 Aug 2011, 11:26 AM
Hello Jayesh,
at this moment i need to use the ViewState and i have already verified that the ViewState are keenping all values, the problem is that the RadGrid cannot get them, when sort, paging or filtering.....
at this moment i need to use the ViewState and i have already verified that the ViewState are keenping all values, the problem is that the RadGrid cannot get them, when sort, paging or filtering.....
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 30 Aug 2011, 10:12 AM
Hello,
after sort, paging or filtering Radgrid again bind the DataSource Automatically if you used radgrid advanced data binding
else
you have to manually assign datasource to radgrid.
itemCommandEvent()
{
if(e.CommandName == RadGrid.SortCommandName)
{
// do your sort logic if you modify
// assign datasource here
// radgrid1.databind();
}
}
Thanks,
Jayesh Goyani
after sort, paging or filtering Radgrid again bind the DataSource Automatically if you used radgrid advanced data binding
else
you have to manually assign datasource to radgrid.
itemCommandEvent()
{
if(e.CommandName == RadGrid.SortCommandName)
{
// do your sort logic if you modify
// assign datasource here
// radgrid1.databind();
}
}
Thanks,
Jayesh Goyani