This is a migrated thread and some comments may be shown as answers.

Viewstate problem

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jouni
Top achievements
Rank 1
Jouni asked on 09 Feb 2009, 08:26 AM
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:
  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); 
                         
 
                    } 
 
 
                } 
            } 
         
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?

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Feb 2009, 02:53 PM
Hi Jouni ,

Instead of disabling ViewSate you can compress it - please check this post for more info:
http://blogs.telerik.com/vladimirenchev/posts/08-12-16/HTTP_Compression_for_your_ASP_NET_AJAX_applications.aspx

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Jouni
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or