Hello everybody,
First i have to tell you little pit background about my case. I have RadGrid is in edit mode all the time.I put grid in the edit mode using following function:
my problem is too big viewstate. So I decieded to turn page viewstate to false. Now problem starts.I collect data from using following function
lineItem.Product = (item["Product"].FindControl("ProductCombo") as RadComboBox).Text; gives me Null.actually every single control returns null reference.when page viewstate is true.everythink works fine .What seems to be problem.Is there any other way handle big viewstate?
First i have to tell you little pit background about my case. I have RadGrid is in edit mode all the time.I put grid in the edit mode using following function:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
if (!IsPostBack||forceEditable) |
{ |
forceEditable = false; |
foreach (GridItem item in RadGrid1.MasterTableView.Items) |
{ |
if (item is GridEditableItem) |
{ |
GridEditableItem editableItem = item as GridDataItem; |
editableItem.Edit = true; |
} |
} |
} |
} |
} |
my problem is too big viewstate. So I decieded to turn page viewstate to false. Now problem starts.I collect data from using following function
private void CollectRowInformation() |
{ |
foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
{ |
foreach (OrderLineItem lineItem in OrderLine) |
{ |
int itemId = int.Parse(item.GetDataKeyValue("OrderLineID").ToString()); |
int lineId = lineItem.OrderLineID; |
if (itemId == lineId) |
{ |
lineItem.Product = (item["Product"].FindControl("ProductCombo") as RadComboBox).Text; |
lineItem.Unit = (item["Unit"].Controls[0] as TextBox).Text; |
lineItem.Info = (item["Product"].FindControl("InfoTextBox") as RadComboBox).Text; |
lineItem.AccountID = (item.FindControl("AccountID") as RadComboBox).SelectedValue; |
lineItem.CostCenterID = (item.FindControl("CostCenterID") as RadComboBox).SelectedValue; |
if ((item["Quantity"].FindControl("Quantity") as RadNumericTextBox).DbValue == null) |
lineItem.Quantity = 0; |
else |
lineItem.Quantity = float.Parse((item["Quantity"].FindControl("Quantity") as RadNumericTextBox).DbValue.ToString()); |
if((item["Price"].FindControl("Price") as RadNumericTextBox).DbValue==null) |
lineItem.Price = 0; |
else |
lineItem.Price = float.Parse((item["Price"].FindControl("Price") as RadNumericTextBox).DbValue.ToString()); |
lineItem.Position = int.Parse((item["Position"].Controls[0] as TextBox).Text); |
if ((item["EstimatedDeliveryDate"].FindControl("EstimatedDeliveryDate") as RadDatePicker).DbSelectedDate == null) |
(item["EstimatedDeliveryDate"].FindControl("EstimatedDeliveryDate") as RadDatePicker).DbSelectedDate = DateTime.Now; |
lineItem.EstimatedDeliveryDate =(DateTime)(item["EstimatedDeliveryDate"].FindControl("EstimatedDeliveryDate") as RadDatePicker).SelectedDate; |
lineItem.Received = (item.FindControl("Received") as CheckBox).Checked; |
lineItem.Invoiced = (item.FindControl("Invoiced") as CheckBox).Checked; |
//lines.Add(lineItem); |
} |
} |
} |