I have a radgrid with various ddl and radcalendars in the cells within the rows that are all editible. What I would like to do is be able to loop through and update all editable cells within the rows of myradgrid at the same time. I have found numerous articles on batch editing when in edit view but I would like to upadate in user view.
Below is my code.
Thanks,
Chad
Code Behind
Below is my code.
Thanks,
Chad
<asp:Panel ID="pnlGrid" runat="server" CssClass="panelGrid">
<telerik:RadGrid ID="myRadGrid" runat="server" Width="90%" Skin="Web20" CssClass="dvGridWrapper" AllowSorting="true">
<PagerStyle AlwaysVisible="true" />
<MasterTableView AutoGenerateColumns="false" Font-Size="10" DataKeyNames="intRecruitId" CommandItemDisplay="Bottom">
<CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" />
<HeaderStyle ForeColor="White" Font-Bold="true" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="#B0C4DE" HorizontalAlign="Center" />
<CommandItemTemplate>
<asp:LinkButton ID="lnkUpdateAll" runat="server" CommandName="UpdateAll" CommandArgument='<%#Bind("intRecruitId")%>'>Update All</asp:LinkButton>
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn DataField="dtRSPStatusChanged" HeaderText="Last Changed" />
<telerik:GridTemplateColumn HeaderText="NAME">
<ItemTemplate>
<asp:LinkButton ID="lnkName" runat="server" Text='<%#Bind("Name")%>' CommandArgument='<%#Bind("intRecruitId")%>' CommandName="pnlOpen" ToolTip="Click to See Data"></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="PHASE" UniqueName="Phase">
<ItemTemplate>
<asp:DropDownList ID="ddlPhase3" runat="server" SelectedValue='<%#Bind("intPhaseId")%>'>
<asp:ListItem Value="1" Text="Red" />
<asp:ListItem Value="2" Text="White1" />
<asp:ListItem Value="3" Text="White2" />
<asp:ListItem Value="4" Text="White3" />
<asp:ListItem Value="5" Text="Blue" />
<asp:ListItem Value="6" Text="Green" />
<asp:ListItem Value="7" Text="Gold" />
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="dtShip" HeaderText="SHIP DATE">
<ItemTemplate>
<telerik:RadDatePicker ID="rdp_dtShip" runat="server" DbSelectedDate='<%#Bind("dtShip")%>' Width="100px"></telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="ddDate" HeaderText="DROP DEAD DATE" />
<telerik:GridTemplateColumn DataField="dtProjReturn" HeaderText="EST RETURN DATE">
<ItemTemplate>
<telerik:RadDatePicker ID="rdp_Return" runat="server" DbSelectedDate='<%#Bind("dtProjReturn")%>' Width="100px"></telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="STATUS" UniqueName="Status">
<ItemTemplate>
<asp:DropDownList ID="ddlStatus3" runat="server" SelectedValue='<%#Bind("intRSPStatusID")%>'>
<asp:ListItem Value="1" Text="Amber" />
<asp:ListItem Value="3" Text="DAT" />
<asp:ListItem Value="4" Text="Discharged" />
<asp:ListItem Value="5" Text="Green" />
<asp:ListItem Value="6" Text="Hardship" />
<asp:ListItem Value="7" Text="Test" />
<asp:ListItem Value="8" Text="OCS" />
<asp:ListItem Value="9" Text="Pend Dis" />
<asp:ListItem Value="10" Text="Prior SVC" />
<asp:ListItem Value="11" Text="Qualified" />
<asp:ListItem Value="12" Text="Red" />
<asp:ListItem Value="13" Text="Shipped" />
<asp:ListItem Value="18" Text="None" />
<asp:ListItem Value="19" Text="NAC" />
<asp:ListItem Value="20" Text="IST" />
<asp:ListItem Value="21" Text="Gold" />
<asp:ListItem Value="22" Text="Not Entered" />
<asp:ListItem Value="23" Text="Recruit Force Pool" />
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="ISSUE" UniqueName="Issue">
<ItemTemplate>
<asp:DropDownList ID="ddlIssue3" runat="server" SelectedValue='<%#Bind("intRSPIssueID")%>' >
<asp:ListItem Value="1" Text="Admin" />
<asp:ListItem Value="2" Text="APFT" />
<asp:ListItem Value="3" Text="Attendance" />
<asp:ListItem Value="5" Text="BCT" />
<asp:ListItem Value="6" Text="Testing" />
<asp:ListItem Value="7" Text="Test2" />
<asp:ListItem Value="8" Text="Education Fail" />
<asp:ListItem Value="9" Text="Family hardship" />
<asp:ListItem Value="10" Text="Legal" />
<asp:ListItem Value="11" Text="Medical" />
<asp:ListItem Value="12" Text="New Trainee" />
<asp:ListItem Value="13" Text="Packet failure" />
<asp:ListItem Value="14" Text="None" />
<asp:ListItem Value="15" Text="Not Entered" />
<asp:ListItem Value="16" Text="Education HSJR" />
<asp:ListItem Value="17" Text="Education HSSR" />
<asp:ListItem Value="18" Text="Education GED" />
<asp:ListItem Value="19" Text="Pend PH2 Date" />
<asp:ListItem Value="20" Text="Pend IST" />
<asp:ListItem Value="21" Text="College" />
<asp:ListItem Value="22" Text="OCS" />
<asp:ListItem Value="23" Text="ROTC" />
<asp:ListItem Value="24" Text="ROTC SMP" />
<asp:ListItem Value="25" Text="Pend OCS Date" />
<asp:ListItem Value="26" Text="Pend RENO Out" />
<asp:ListItem Value="27" Text="Pending Commission" />
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="EDUCATION" UniqueName="Ed">
<ItemTemplate>
<asp:DropDownList ID="ddlEd3" runat="server" SelectedValue='<%#Bind("intRSPEdID")%>' >
<asp:ListItem Value="1" Text="N/A" />
<asp:ListItem Value="2" Text="HSSR" />
<asp:ListItem Value="3" Text="HSJR" />
<asp:ListItem Value="4" Text="GED +" />
<asp:ListItem Value="5" Text="GED" />
<asp:ListItem Value="6" Text="GRAD" />
<asp:ListItem Value="7" Text="COLLEGE" />
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="NOTES">
<ItemTemplate>
<asp:Image ID="imgLooker" runat="server" ImageUrl="~/Images/ViewResources.gif" ImageAlign="Middle" BorderStyle="None" />
<asp:PopupControlExtender ID="popInfo" runat="server" PopupControlID="pnlPop" TargetControlID="imgLooker" DynamicContextKey='<% #Eval("intRSPNotesID")%>'
DynamicControlID="pnlpop" DynamicServiceMethod="GetNotes" Position="bottom"></asp:PopupControlExtender>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="strRSPSiteLocation" HeaderText="RSP SITE" />
<telerik:GridBoundColumn DataField="strUIC" HeaderText="UIC" />
<telerik:GridTemplateColumn HeaderText="UPDATE">
<ItemTemplate>
<asp:LinkButton ID="lnkUpdate" runat="server" Text="Update" ToolTip="Click to Save Data" CommandArgument='<%#Bind("intRecruitId")%>' CommandName="Update"></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<BatchEditingSettings EditType="Cell" />
</MasterTableView>
</telerik:RadGrid>
Code Behind
If (e.CommandName = "UpdateAll") Then
Dim recruitid As Integer = Convert.ToInt32(e.CommandArgument = "intRecruitId")
'Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim Phase As DropDownList = DirectCast(e.Item.FindControl("ddlPhase3"), DropDownList)
Dim Status As DropDownList = DirectCast(e.Item.FindControl("ddlStatus3"), DropDownList)
Dim Issue As DropDownList = DirectCast(e.Item.FindControl("ddlIssue3"), DropDownList)
Dim Ed As DropDownList = DirectCast(e.Item.FindControl("ddlEd3"), DropDownList)
Dim dtShip As TextBox = DirectCast(e.Item.FindControl("txtdtShip"), TextBox)
Dim dtReturn As TextBox = DirectCast(e.Item.FindControl("txtProjRtn"), TextBox)
Dim myDataGridItem As DataGridItem
For Each DataGridItem In myRadGrid.Items
 
sql =
"Update tblRSP SET dtProjReturn = '" & sanitizeString(dtReturn.Text) & "', intRSPStatusID = " & Status.SelectedValue & ", intRSPIssueID = " & Issue.SelectedValue & ", INTRSPEdID = " & Ed.SelectedValue & ", intPhaseID = " & Phase.SelectedValue & "" _
&
" Where intRecruitId =" & recruitid & " Update Recruit SET dtShip = '" & sanitizeString(dtShip.Text) & "' Where intRecruitId =" & recruitid
Response.Write(sql)
Response.End()
insertUpdateDelete(sql)
myRadGrid.Rebind()
Next
End If