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

RadGrid and ViewState

1 Answer 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 22 Aug 2008, 03:51 PM
Here is the scenario I am presented with. 

  1. RadGrid with 100 rows and a checkbox column for selecting rows.
  2. RadGrid takes 30 seconds to load.
  3. Issue is with the intial load and the database and we are not allowed to modfiy the data so we have to work with it.
  4. Above the RadGrid is a dropdownlist to assign another User to a product.
  5. The RadGrid has a column for User.
  6. When selecting another User from the dropdownlist I would like the checked rows in the grid to change the User in the grid to the one selected in the Dropdownlist WITHOUT rebinding the grid from the database and updating the selected rows with the dropdownlist value.

Could I do it in the Button_Click by just changing the row in the grid by modifying the selected rows that are held in View State?  If so, HELP please.

This is my Code behind from the Grid

 protected void ButtonAssign_Click(object sender, EventArgs e)  
    {  
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)  
        {  
            CheckBox chkbx = (CheckBox)item["ClientSelectColumn"].Controls[0];  
            if (chkbx.Checked)  
            {  
                ProductBLL myData = new ProductBLL();  
                string productId = item["ID"].Text.ToString();  
                string user = Convert.ToString(DropDownListUserNew.SelectedValue);  
                myData.ProductId = Convert.ToInt32(productId );  
                myData.User = user ;  
                myData.UpdateUser();  
I would like to update the ViewState so the RadGrid Column and Row have the new user 
            }  
        }  
    } 

Thank you!

1 Answer, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 26 Aug 2008, 10:28 AM
Hello George,

It is not possible to update the records in the Grid without rebinding it. For your scenario I would recommend you to use client-side binding. Here are some resources that might be useful:

http://blogs.telerik.com/VladimirEnchev/Posts/08-07-24/Telerik_RadGrid_for_ASP_NET_AJAX_Q2_2008_client-side_edit_using_templates.aspx?ReturnURL=%2fVladimirEnchev%2fPosts.aspx
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/Client/InsertUpdateDelete/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/client-side-binding.html


Sincerely yours,
Pavel
the Telerik team

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