I need to send an email to a user if the rejected checkbox is selected.
What I am needing to do is check the value of the rejected check box when the update button is press and if it is true send the email.
Can anyone give a clue as how to get this value on RadGrid4_ItemUpdated Sub. I code in VB.
10 Answers, 1 is accepted
Please, find below the code to access the checkbox control and inspect its value:
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem) |
Dim checkBox As CheckBox = item("ColumnUniqueName").FindControl("CheckBoxID") |
If checkBox.Checked Then |
Else |
End If |
End If |
I hope this helps.
Regards,
Tsvetoslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim checkBox As CheckBox = item("Rejected").FindControl("checkbox2")<----??????????
If checkBox.Checked Then
MsgBox(
" Job was Rejected")
End If
Could you, please, post your aspx for the column.
Thank you.
Kind regards,
Tsvetoslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Here is the radgrid that contains the rejected checkbox the edit form is auto generated.
<telerik:RadGrid
ID="RadGrid4" runat="server" AllowFilteringByColumn="True"
AllowPaging="True" AllowSorting="True" DataSourceID="SqlDataPending"
GridLines="None" Skin="Black" AllowAutomaticUpdates="True"
AutoGenerateColumns="False" AutoGenerateEditColumn="True">
<MasterTableView DataKeyNames="JobNumber"
DataSourceID="SqlDataPending" pagesize="20" CellSpacing="-1"><RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn><ExpandCollapseColumn><HeaderStyle Width="20px" /></ExpandCollapseColumn>
<Columns><telerik:GridEditCommandColumn HeaderText="Edit"></telerik:GridEditCommandColumn><telerik:GridCheckBoxColumn DataField="approved" DataType="System.Boolean"
HeaderText="approved" SortExpression="approved" UniqueName="approved"
Visible="False"></telerik:GridCheckBoxColumn><telerik:GridCheckBoxColumn DataField="rejected" DataType="System.Boolean"
HeaderText="rejected" SortExpression="rejected" UniqueName="rejected"
Visible="False"></telerik:GridCheckBoxColumn><telerik:GridBoundColumn DataField="notes" HeaderText="notes"
SortExpression="notes" UniqueName="notes" Visible="False"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="JobNumber" DataType="System.Int32"
HeaderText="JobNumber" ReadOnly="True" SortExpression="JobNumber"
UniqueName="JobNumber"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="Juvenile" DataType="System.Double"
HeaderText="Juvenile" ReadOnly="True" SortExpression="Juvenile"
UniqueName="Juvenile"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="Stat" DataType="System.Int16"
HeaderText="Stat" ReadOnly="True" SortExpression="Stat" UniqueName="Stat"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="Case #" HeaderText="Case #" ReadOnly="True"
SortExpression="Case #" UniqueName="Case #"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="Dictating Officer"
HeaderText="Dictating Officer" ReadOnly="True"
SortExpression="Dictating Officer" UniqueName="Dictating Officer"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="Date Dictated" DataType="System.DateTime"
HeaderText="Date Dictated" ReadOnly="True" SortExpression="Date Dictated"
UniqueName="Date Dictated"></telerik:GridBoundColumn><telerik:GridBoundColumn DataField="Date Typed" DataType="System.DateTime"
HeaderText="Date Typed" ReadOnly="True" SortExpression="Date Typed"
UniqueName="Date Typed"></telerik:GridBoundColumn></Columns><EditFormSettings><EditColumn UniqueName="EditCommandColumn1"></EditColumn></EditFormSettings><ItemStyle
Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
Wrap="True" /><GroupHeaderItemStyle Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
HorizontalAlign="Left" Wrap="True" /><AlternatingItemStyle
Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
Wrap="True" />
<PagerStyle Position="TopAndBottom" />
<HeaderStyle Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
HorizontalAlign="Left" Wrap="True" /></MasterTableView><ClientSettings><Selecting AllowRowSelect="True" /></ClientSettings><FilterMenu EnableTheming="True"><CollapseAnimation Duration="200" Type="OutQuint" /></FilterMenu></telerik:RadGrid>
In this case, you should access the first control in the table cells controls collection:
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
.... |
Dim checkBox As CheckBox = TryCast(item("rejected").Controls(0),CheckBox) |
.... |
End If |
Best Regards,
Tsvetoslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Protected Sub RadGrid4_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid4.UpdateCommand
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
Dim checkBox As CheckBox = TryCast(item("rejected").Controls(0), CheckBox)
if checkbox.checked then
//Do my stuff here
End If
End if
End Sub
The code snippet in my last post was meant to be an addition to the one in my previous post, so you still need the declaration statement:
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem) |
Best Regards,
Tsvetoslavthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Great Thanks I don't get any errors anymore however it does not seem to be seeing that the rejected checkbox was checked and it is not sending an email out. I see that we are checking to make sure that we are in editmode should I be running this at Radgrid4_updatecommand or at some other point in the update process. I have tried this also at Radgrid4_Itemupdated as well and still get the same results it just updates the record and sends no email. I have checked the email routine by removing the if statement from it and it sends the email just fine. Again thanks for all your help. Below is the entire Sub.
Protected Sub RadGrid4_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid4.UpdateCommand
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim checkBox As CheckBox = TryCast(item("rejected").Controls(0), CheckBox)
If checkBox.Checked Then
Dim mailman As New Chilkat.MailMan()
' Any string passed to
Dim td
td =
Date.Today
mailman.UnlockComponent(
"Anything")
mailman.SmtpHost =
"smtp.charter.net"
mailman.SmtpUsername =
"myusername"
mailman.SmtpPassword =
"mypassword"
Dim email As New Chilkat.Email()
email.Subject =
"" 'Subjecttxt
email.Body = ((
"Hello Todays Date is ") + td)
email.AddTo(
"test@test.com")
email.From = (
If (Not mailman.SendEmail(email)) Then
MsgBox(mailman.LastErrorXml)
Else
MsgBox(
"Mail Sent!")
mailman.CloseSmtpConnection()
End If
End If
End If
End Sub
I could not reproduce this problem.
Please, take a look at the attached sample and see if you can reproduce the problem with it.
Thank you.
Best Regards,
Tsvetoslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.