Client multi select and update all selected serverside?

8 posts, 0 answers
  1. Johan
    Johan avatar
    2 posts
    Member since:
    Feb 2008

    Posted 12 Nov 2008 Link to this post

    Is it possible to update all selected rows that are selected in the radgrid by client select with a serverside method? 

    I want to update all rows with a value that are in a textbox outside the grid but can't get it to work and just wonder if it is possible.

    /Johan
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Nov 2008 Link to this post

    Hi Johan,

    One suggestion will be to set the entire Grid rows in edit mode and set EditMode to InPlace. You can access the selected rows text on clicking a button outside the Grid as shown below.

    ASPX:
    <MasterTableView DataSourceID="SqlDataSource1"   EditMode="InPlace"    > 

    CS:

    //to set the entire Grid rows in edit mode
      protected void RadGrid1_PreRender(object sender, EventArgs e) 
        { 
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
            { 
                item.Edit = true
            } 
            RadGrid1.Rebind(); 
        } 



    //to access the selected Grid rows which are in edit mode in the Button's Click event

    protected void Button1_Click(object sender, EventArgs e) 
        { 
            foreach (GridDataItem item in RadGrid1.SelectedItems) 
            { 
                TextBox txtbx = (TextBox)item["ProductName"].Controls[0]; 
                string strtxt = txtbx.Text; 
                // code for updating the row
            } 
            
        } 


    Thanks
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Revital Keren
    Revital Keren avatar
    26 posts
    Member since:
    Jun 2008

    Posted 16 Dec 2008 Link to this post

    Hi Shinu,
    I am after the same thing - I have a GridClientSelectColumn (which I add programmatically), and also

    AllowMultiRowSelection =

    true; and

     

    ClientSettings.Selecting.AllowRowSelect =

    true;

     


    the problem is that when the onclick event is cought the SelecteItems.Count of the grid is always 0.

    Do you have an Idea of what I should do?

    thanks,
    Revital
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Dec 2008 Link to this post

    Hi Revital,

    Is your Grid rows in edit mode or normal mode? Are you trying to access the selected rows in the Click event of a button? Could you please send your aspx code as well.

    Shinu.
  6. Revital Keren
    Revital Keren avatar
    26 posts
    Member since:
    Jun 2008

    Posted 17 Dec 2008 Link to this post

    Hi Shinu,
    my grid is in normal mode , and yes I am trying to access them in the click event of the button (server side).
    My CustomGrid is inherited from the RadGrid and resided in a content page . here is the contentPlaceholder in which the grid and button are defined:
    <asp:Content ID="centerContent" ContentPlaceHolderID="InfoContentPlaceHolder"   
        runat="server">  
        <link href="../ReformaSkin/Window.ReformaSkin.css" rel="stylesheet" type="text/css" /> 
        <link href="../ReformaSkin/Calendar.ReformaSkin.css" rel="stylesheet" type="text/css" /> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        </telerik:RadAjaxManager> 
        <table dir="rtl" style="width: 100%;">  
            <tr align="right">  
                <contenttemplate> 
                    <td align="right"><span class="SubTitle" dir="rtl">מידע על   
                            <telerik:RadScriptBlock ID="subjectScriptBlock" runat="server">  
                                <%=ViewState["Subject"]%> 
                            </telerik:RadScriptBlock> 
                        </span> 
                    </td> 
                    <td align="left">  
                        <asp:Button ID="btnSwitchUpdate" runat="server" Style="z-index: 1;width: 105px;" Text="עבור למצב עדכון" Visible="False" OnClick="btnSwitchUpdate_Click" /> 
                    </td> 
                </contenttemplate> 
            </tr> 
            <tr> 
                <td colspan="2">  
                <asp:PlaceHolder runat="server" ID="errPlaceHolder"></asp:PlaceHolder> 
                </td> 
            </tr> 
            <tr> 
                <td colspan="2">  
                <contenttemplate> 
                <asp:PlaceHolder ID="dataObjectsPlaceHolder" runat="server"></asp:PlaceHolder> 
                        <ref:CustomGrid ID="entityGrid" runat=server onneeddatasource="entityGrid_NeedDataSource"   
                        onupdatecommand="entityGrid_UpdateCommand"  Width="100%"   
                        onitemcreated="entityGrid_ItemCreated" 
                        onitemdatabound="entityGrid_ItemDataBound">  
                        </ref:CustomGrid> 
                </contenttemplate> 
                </td> 
            </tr> 
            <tr align="left">  
                <td align="left" colspan="2">  
                    <contenttemplate> 
                        <asp:PlaceHolder  ID="PlaceHolder1" runat="server">  
                        </asp:PlaceHolder> 
                    </contenttemplate> 
                </td> 
            </tr> 
        </table> 
        <p> 
            <asp:Button ID="btnInfoRecieved" runat="server" Text="צווי מידע שהתקבלו" Visible="False" /> 
            <asp:Button ID="btnSaveUpdate" runat="server" Text="שמור עדכון" Visible="False" OnClick="btnSaveUpdate_Click" /> 
            <asp:Button ID="btnPrint" runat="server" Text="הדפס" Visible="False"   
                onclick="btnPrint_Click" /> 
            <asp:Button ID="btnMarkAll" runat="server" Text="סמן הכל" Visible="False" /> 
        </p> 
          
    </asp:Content> 
    my button is btnPrint.

  7. Revital Keren
    Revital Keren avatar
    26 posts
    Member since:
    Jun 2008

    Posted 17 Dec 2008 Link to this post

    Hi Shinu,
    I found my mistake - I was doing a grid Rebind in the Page_Load, and after that , of course, my selected items disappeared.

    thanx for your help and quick response,
    Revital
  8. Marc Arbesman
    Marc Arbesman avatar
    7 posts
    Member since:
    Feb 2006

    Posted 27 Jan 2009 Link to this post

    Hi Shinu,

    I am having the same problem and haven't found an answer for my issue yet.  Using the GridClientSelectColumn and have AllowMultiRowSelection = true and in the clientsettings have AllowRowSelect = true.  Edit mode is set to in-place and accessing through a button click event.

    Trying to loop through all items with a for each loop to check for all selected items.  Issue is that I keep getting a count of 0.

     

     

     

     

    For Each item As GridDataItem In radgSomeRadGrid.SelectedItems

     

        'Deleting the selected item from the database

     

        Dim someDBObject As New dBObject

        someDBObject.LoadByPrimaryKey(item.GetDataKeyValue(

    "idSomeItemValue"))

     

     

        someDBObject.MarkAsDeleted()

        someDBObject.Save()

     

    Next

    Thanks,
    marc

     

     

     

     

  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Jan 2009 Link to this post

    Hi Marc,

    Access the Selected rows in Grid using the following code snippet.

    CS:
     protected void Button1_Click(object sender, EventArgs e) 
        { 
            //to access the Selected rows in Grid 
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
            { 
                if (item.Selected) 
                {  
                 // delete the selected rows 
                } 
            }  
           
        } 


    You can try the following code snippet to access the Grid rows which are in edit mode.

    CS:
     protected void Button2_Click(object sender, EventArgs e) 
        { 
            //to access the rows in edit mode 
            foreach (GridEditableItem edititem in RadGrid1.MasterTableView.GetItems(GridItemType.EditItem)) 
            { 
                TextBox txtbx = (TextBox)edititem["columnUniqueName"].Controls[0]; 
                string strtxt = txtbx.Text; 
                
            }  
      } 


    Thanks
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017