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
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
7 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 13 Nov 2008, 04:59 AM
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:
CS:
//to set the entire Grid rows in edit mode
//to access the selected Grid rows which are in edit mode in the Button's Click event
Thanks
Shinu.
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.
0

Revital Keren
Top achievements
Rank 1
answered on 16 Dec 2008, 04:45 PM
Hi Shinu,
I am after the same thing - I have a GridClientSelectColumn (which I add programmatically), and also
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
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
0

Shinu
Top achievements
Rank 2
answered on 17 Dec 2008, 04:56 AM
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.
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.
0

Revital Keren
Top achievements
Rank 1
answered on 17 Dec 2008, 08:31 AM
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:
my button is btnPrint.
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> |
0

Revital Keren
Top achievements
Rank 1
answered on 17 Dec 2008, 09:57 AM
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
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
0

Marc Arbesman
Top achievements
Rank 2
answered on 27 Jan 2009, 08:14 PM
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.
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
0

Shinu
Top achievements
Rank 2
answered on 28 Jan 2009, 05:27 AM
Hi Marc,
Access the Selected rows in Grid using the following code snippet.
CS:
You can try the following code snippet to access the Grid rows which are in edit mode.
CS:
Thanks
Shinu.
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.