J
Jeremy Martin
Hi,
I have a Master Detail Detail DataGrid which is setup like a dynamic
score card. The user clicks on the score "DataCell" and it fires a JS
onclick event which sets the property of a Hidden Input Type and
displays an appropriate image. "Visual representation of a mark eg tick
cross"
Now there us usually a couple of hundred possibilities on the form and
I cannot use Paging on the grid.
Example of HTML output of a Hidden Tag
<input name="TPG:_ctl9AG:_ctl3OG:_ctl2:1imgMark_h"
id="TPG__ctl9_PAG__ctl3_POG__ctl2_1imgMark_h" type="hidden" value="0" />
This setup works really well except for a couple of problems.
1. The viewstate is huge ~200K. I currently override the
SavePageStateToPersistenceMedium procedure and store it in a
SQLDatabase along with my Session Data. However I found that it takes
rougly 1 second to serialize and deserialize and uses alot of
processing power.
My alternative was download the whole Viewstate but on postback i got
viewstate corrupt errors.
2. I tried disabling the viewstate which ofcourse helps but now my
results do not get posted back and saved.
So I suppose the questions I have are.
Can I shrink the viewstate somehow by not storing everything about the
datagrid
OR
Should I be using an alternative method to save my results. Currently I
am doing below on OnInit whenever they click the save button. However
when ViewState is disabled on the datagrid none of items or controls
are available on PostBack.
for i := 0 to self.Items.Count -1 do
Begin
If (self.Items.itemType = ListItemType.Item) OR
(self.Items.itemType = ListItemType.AlternatingItem) OR
(self.Items.itemType = ListItemType.SelectedItem) Then
Begin
drp := self.Items.FindControl('OUTCOME_ATTITUDE') as
DropDownList;
if Assigned(drp) then
PriOutcomes :=
TPriOutcomes(OutComeData.Item[self.Items.ItemIndex]);
if PriOutcomes.Attitude then
PriOutcomes.Behaviour := drp.SelectedIndex;
PriOutcomes :=
TPriOutcomes(OutComeData.Item[self.Items.ItemIndex]);
for i2 := 3 to self.Columns.Count -1 do
Begin
placeholder := self.Items.Cells[i2].Controls[0] as
System.Web.UI.WebControls.PlaceHolder;
hid := placeholder.Controls[0] as
System.Web.UI.HtmlControls.HtmlInputHidden;
ViewState[hid.ClientID] := hid.Value;
levelidx := i2 - 2;
try
PriMark :=
(PriOutcomes.GetProperty('Level'+levelidx.ToString) as TPRIMark);
except
PriMark := (PriOutcomes.GetProperty('LevelNA') as TPRIMark);
end;
if (Assigned(PriMark)) then
if (hid.Value <> '0') and (hid.Value <> '') then
PriMark.FChecked := True
else
PriMark.FChecked := False;
End;
end;
Any advice on this one is greatly appreciated.
Cheers
Jeremy
I have a Master Detail Detail DataGrid which is setup like a dynamic
score card. The user clicks on the score "DataCell" and it fires a JS
onclick event which sets the property of a Hidden Input Type and
displays an appropriate image. "Visual representation of a mark eg tick
cross"
Now there us usually a couple of hundred possibilities on the form and
I cannot use Paging on the grid.
Example of HTML output of a Hidden Tag
<input name="TPG:_ctl9AG:_ctl3OG:_ctl2:1imgMark_h"
id="TPG__ctl9_PAG__ctl3_POG__ctl2_1imgMark_h" type="hidden" value="0" />
This setup works really well except for a couple of problems.
1. The viewstate is huge ~200K. I currently override the
SavePageStateToPersistenceMedium procedure and store it in a
SQLDatabase along with my Session Data. However I found that it takes
rougly 1 second to serialize and deserialize and uses alot of
processing power.
My alternative was download the whole Viewstate but on postback i got
viewstate corrupt errors.
2. I tried disabling the viewstate which ofcourse helps but now my
results do not get posted back and saved.
So I suppose the questions I have are.
Can I shrink the viewstate somehow by not storing everything about the
datagrid
OR
Should I be using an alternative method to save my results. Currently I
am doing below on OnInit whenever they click the save button. However
when ViewState is disabled on the datagrid none of items or controls
are available on PostBack.
for i := 0 to self.Items.Count -1 do
Begin
If (self.Items.itemType = ListItemType.Item) OR
(self.Items.itemType = ListItemType.AlternatingItem) OR
(self.Items.itemType = ListItemType.SelectedItem) Then
Begin
drp := self.Items.FindControl('OUTCOME_ATTITUDE') as
DropDownList;
if Assigned(drp) then
PriOutcomes :=
TPriOutcomes(OutComeData.Item[self.Items.ItemIndex]);
if PriOutcomes.Attitude then
PriOutcomes.Behaviour := drp.SelectedIndex;
PriOutcomes :=
TPriOutcomes(OutComeData.Item[self.Items.ItemIndex]);
for i2 := 3 to self.Columns.Count -1 do
Begin
placeholder := self.Items.Cells[i2].Controls[0] as
System.Web.UI.WebControls.PlaceHolder;
hid := placeholder.Controls[0] as
System.Web.UI.HtmlControls.HtmlInputHidden;
ViewState[hid.ClientID] := hid.Value;
levelidx := i2 - 2;
try
PriMark :=
(PriOutcomes.GetProperty('Level'+levelidx.ToString) as TPRIMark);
except
PriMark := (PriOutcomes.GetProperty('LevelNA') as TPRIMark);
end;
if (Assigned(PriMark)) then
if (hid.Value <> '0') and (hid.Value <> '') then
PriMark.FChecked := True
else
PriMark.FChecked := False;
End;
end;
Any advice on this one is greatly appreciated.
Cheers
Jeremy