I keep struggling with the following issue: In the editform of a hierarchical grid I have a combobox called ddlStatus. When the status changes into 'Accepted' an automatic mail must be sent. This is no problem.
Here's my issue: when the status changes into 'Accepted' the RadDateInput 'DateSendDataSteward' must automatically be filled with the date of today. I tried it with several codes (see my last one on row 67 to 70), but decided to post a thread on the forum.
Here's my issue: when the status changes into 'Accepted' the RadDateInput 'DateSendDataSteward' must automatically be filled with the date of today. I tried it with several codes (see my last one on row 67 to 70), but decided to post a thread on the forum.
| Protected Sub gvProjects_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles gvProjects.ItemCommand | |
| 'trigger for retrieving the ProjectId | |
| If (e.CommandName = RadGrid.UpdateCommandName AndAlso e.Item.OwnerTableView.DataSourceID = "dsTasks") Then | |
| Dim TaskId As String = e.Item.OwnerTableView.Items(e.Item.ItemIndex)("TaskId").Text | |
| gvProjects.Controls.Add(New LiteralControl("Updated item primary key value is: " & TaskId & "<br/>")) | |
| If TypeOf e.Item Is GridDataItem Then | |
| Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) | |
| Dim chkbxlst As CheckBoxList = DirectCast(item("TempCol").FindControl("chkTasks"), CheckBoxList) | |
| End If | |
| Dim editItem As GridEditFormItem = CType(e.Item, GridEditFormItem) | |
| Dim ddlStatus As RadComboBox = TryCast(FindControl("ddlStatus"), RadComboBox) | |
| Dim cell1 As TableCell = editItem("ddlStatus") | |
| Dim Status As String = (CType(cell1.Controls(0), RadComboBox)).Text | |
| Dim DateSendDataSteward As RadDateInput = TryCast(FindControl("DateSendDataSteward"), RadDateInput) | |
| Dim cellx As TableCell = editItem("DateSendDataSteward") | |
| Dim MailDataSteward As String = (CType(cellx.Controls(0), RadDateInput)).Text | |
| If Status = "Accepted" Then | |
| If MailDataSteward = "" Then | |
| Dim cell2 As TableCell = editItem("TaskDescription") | |
| Dim Task As String = (CType(cell2.Controls(0), TextBox)).Text | |
| Dim cell3 As TableCell = editItem("EstimatedReadyDate") | |
| Dim EstimatedReadyDate As String = (CType(cell3.Controls(0), RadDatePicker)).SelectedDate | |
| Dim cell4 As TableCell = editItem("UserId") | |
| Dim User As Integer = (CType(cell4.Controls(0), RadComboBox)).SelectedValue | |
| Dim sql As String = _ | |
| "Select UserId, Username, Name, Mailaddress " & _ | |
| "from tblUsers " & _ | |
| "where UserId = '" & User & "'" | |
| Dim dr As SqlDataReader | |
| dr = DBPortal.OpenReader(sql) | |
| If dr.Read Then | |
| Dim Name As String = dr("Name").ToString | |
| Dim MailAddress As String | |
| MailAddress = dr("mailaddress") | |
| Dim Mail As New MailMessage | |
| Mail.To.Add(MailAddress) | |
| Mail.Subject = "New task" | |
| Mail.Body = "Dear " & Name & "," & vbCrLf & vbCrLf & "Here's a new task for you." & vbCrLf & vbCrLf & "Taskname: " & Task & vbCrLf & "Deadline: " & EstimatedReadyDate & vbCrLf & vbCrLf & "Ga naar www.DataPlanner.nl. " | |
| Try | |
| Dim client As New SmtpClient() | |
| client.Send(Mail) | |
| Catch ex As Exception | |
| While Not (ex.InnerException Is Nothing) | |
| exex = ex.InnerException | |
| End While | |
| End Try | |
| End If | |
| Dim Today As Date | |
| Today = Now() | |
| Dim editItemx As GridEditFormItem = CType(e.Item, GridEditFormItem) | |
| editItemx("DateSendDataSteward").Text = Today | |
| End If | |
| End If | |
| Dim parentItem As GridDataItem = e.Item.OwnerTableView.ParentItem | |
| If (Not parentItem Is Nothing) Then | |
| gvProjects.Controls.Add(New LiteralControl("Parent item primary field value is: " & _ | |
| CType(parentItem.OwnerTableView.DataKeyValues(parentItem.ItemIndex)("ProjectId"), String))) | |
| End If | |
| End If | |
| If (e.CommandName = RadGrid.InitInsertCommandName Or e.CommandName = RadGrid.PerformInsertCommandName) Then | |
| 'If (e.Item.OwnerTableView.DataSourceID = "dsTasks") Then | |
| Dim parentItem = CType(e.Item.OwnerTableView.ParentItem, GridDataItem) | |
| If (Not parentItem Is Nothing) Then | |
| gvProjects.Controls.Add(New LiteralControl("Parent item primary field value is: " & _ | |
| CType(parentItem.OwnerTableView.DataKeyValues(parentItem.ItemIndex)("ProjectId"), String))) | |
| End If | |
| 'End If | |
| End If | |
| End Sub |