Response.Write("<
script
type
=
'text/javascript'
src
=
'" + Request.ApplicationPath + "/Telerik.Web.UI.WebResource.axd?compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d1.0.61025.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a1f0f78f9-0731-4ae9-b308-56936732ccb8%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3ad89f6e67-3ab0-4fcf-b5f1-b51b735ae3d9%3a16e4e7cd%3af7645509%3a24ee1bba%3a1e771326%3aaa288e2d'
></
script
>");
CommandItemSettings
ExportToPdfText="Export to Pdf"
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"EntityDataSource1"
AutoGenerateEditColumn
=
"True"
Width
=
"500px"
OnUpdateCommand
=
"RadGrid1_UpdateCommand"
OnInsertCommand
=
"RadGrid1_InsertCommand"
AutoGenerateColumns
=
"False"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
GridLines
=
"None"
ShowGroupPanel
=
"True"
>
<
ClientSettings
AllowDragToGroup
=
"True"
>
</
ClientSettings
>
<
MasterTableView
DataSourceID
=
"EntityDataSource1"
DataKeyNames
=
"OrgID"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"OrgID"
HeaderText
=
"OrgID"
ReadOnly
=
"True"
SortExpression
=
"OrgID"
UniqueName
=
"OrgID"
DataType
=
"System.Int32"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrgName"
HeaderText
=
"OrgName"
SortExpression
=
"OrgName"
UniqueName
=
"OrgName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Address"
HeaderText
=
"Address"
SortExpression
=
"Address"
UniqueName
=
"Address"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"City"
HeaderText
=
"City"
SortExpression
=
"City"
UniqueName
=
"City"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"State"
HeaderText
=
"State"
SortExpression
=
"State"
UniqueName
=
"State"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Zip"
HeaderText
=
"Zip"
SortExpression
=
"Zip"
UniqueName
=
"Zip"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Phone"
HeaderText
=
"Phone"
SortExpression
=
"Phone"
UniqueName
=
"Phone"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Fax"
HeaderText
=
"Fax"
SortExpression
=
"Fax"
UniqueName
=
"Fax"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:EntityDataSource
ID
=
"EntityDataSource1"
runat
=
"server"
ConnectionString
=
"name=G3TEntities"
DefaultContainerName
=
"G3TEntities"
EnableFlattening
=
"False"
EnableInsert
=
"True"
EntitySetName
=
"Orgs"
EnableUpdate
=
"True"
>
</
asp:EntityDataSource
>
Hi,
I'm currently using the RadEditor to update html content added into a Gridview. I modified the sample code but it doesn't work the same? How it works is the person can add their content, visually with all the styles of bold, red text, etc. Then submit that to the database. If they want to edit that html page, they just go to the Gridview, click edit, and the content from the grid will populate the editor where they can edit it, again visually, and then resubmit overwriting the content that's there. My problem is I can submit to the database but I can't pull it back out meaning edit doesn't work nor does delete? Here's the code:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
' Important!!! The method is called AFTER Page_Load method is executed, so make sure you do not
' inadvertently overwrite the editor content there before you process it here!
Public Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Dim connection As SqlConnection = CreateConnection()
Dim command As SqlCommand = Nothing
If EditedNews.Value <> String.Empty Then
command = New SqlCommand("UPDATE ElectPageEditor SET NewsDate = GETDATE(), NewsText = @NewsText WHERE NewsID = @NewsID", connection)
command.Parameters.AddWithValue("@NewsText", NewsEditor.Content)
command.Parameters.AddWithValue("@NewsID", Convert.ToInt32(EditedNews.Value))
Else
command = New SqlCommand("INSERT INTO ElectPageEditor (NewsDate, NewsText) VALUES (GETDATE(), @NewsText)", connection)
command.Parameters.AddWithValue("@NewsText", NewsEditor.Content)
End If
Try
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
lblError.Text = "Error in submit form for " & ex.Message
Finally
connection.Close()
End Try
Me.Response.Redirect(Me.Request.Url.PathAndQuery)
End Sub
Private Function CreateConnection() As SqlConnection
Dim _connectionString As String = ConfigurationManager.ConnectionStrings("VRASConnectionString").ConnectionString
Return New SqlConnection(_connectionString)
End Function
Protected Sub ReadAllRecords()
Dim connection As SqlConnection = CreateConnection()
Try
connection.Open()
Dim command2 As New SqlCommand("SELECT NewsID, NewsDate, NewsText FROM ElectPageEditor", connection)
NewsGrid.DataSource = command2.ExecuteReader()
NewsGrid.DataBind()
Catch ex As Exception
lblError.Text = "Error in application " & ex.Message
Finally
connection.Close()
End Try
End Sub
Protected Sub NewsGrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles NewsGrid.RowCommand
Dim connection As SqlConnection = CreateConnection()
Dim row As GridViewRow = TryCast(NewsGrid.Rows(e.CommandArgument), GridViewRow)
NewsGrid.DataKeys(row.RowIndex).Value.ToString()
If e.CommandName = "Delete" Then
Dim com As New SqlCommand("DELETE FROM ElectPageEditor WHERE NewsID = @NewsID", connection)
com.Parameters.AddWithValue("@NewsID", row.Cells(0).Text)
Try
connection.Open()
com.ExecuteNonQuery()
Catch ex As Exception
lblError.Text = "Error running command. " & ex.Message
Finally
connection.Close()
End Try
ElseIf e.CommandName = "Edit" Then
Dim command As New SqlCommand("SELECT NewsText FROM ElectPageEditor WHERE NewsID = @NewsID", connection)
command.Parameters.AddWithValue("@NewsID", row.Cells(0).Text)
Try
connection.Open()
Dim record As SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
If record.Read() Then
NewsEditor.Content = record.GetString(0)
EditedNews.Value = row.Cells(0).Text
Else
NewsEditor.Content = ""
EditedNews.Value = ""
End If
' Will close the connection as well
record.Close()
Catch ex As Exception
lblError.Text = "Error modifying information. " & ex.Message
Finally
connection.Close()
End Try
End If
' Add code to delete row from data source.
ReadAllRecords()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ReadAllRecords()
End If
End Sub
End Class
Reminder='<%# Bind("Reminder") %>'
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
MarkFirstMatch
=
"True"
HighlightTemplatedItems
=
"true"
EnableLoadOnDemand
=
"true"
ShowMoreResultsBox
=
"true"
Width
=
"200px"
Skin
=
"Default"
DropDownWidth
=
"350px"
OnItemsRequested
=
"RadComboBox1_ItemsRequested"
DataTextField
=
"FullName"
DataValueField
=
"DirID"
OnClientItemsRequestFailed
=
"OnClientItemsRequestFailedHandler"
>
<
HeaderTemplate
>
<
ul
>
<
li
class
=
"col1"
>File ID</
li
>
<
li
class
=
"col2"
>Client Name</
li
>
<
li
class
=
"col3"
>Birth Date</
li
>
</
ul
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
ul
>
<
li
class
=
"col1"
>
<%# DataBinder.Eval(Container.DataItem, "DirID") %></
li
>
<
li
class
=
"col2"
>
<%# DataBinder.Eval(Container.DataItem, "FullName") %></
li
>
<
li
class
=
"col3"
>
<%# DataBinder.Eval(Container.DataItem, "Birthdate", "{0:d}") %></
li
>
</
ul
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
<
asp:ObjectDataSource
ID
=
"odsGetTaskStartTimes"
runat
=
"server"
TypeName
=
"DMCproWebApp.BALHelper"
SelectMethod
=
"GetTaskStartTimes"
/>
<
asp:ObjectDataSource
id
=
"odsGetProgramServicesFast"
runat
=
"server"
TypeName
=
"DMCproWebApp.BALHelper"
SelectMethod
=
"GetProgramServicesFast"
>
<
SelectParameters
>
<
asp:ControlParameter
Name
=
"ProgramNumber"
ControlID
=
"hiddenProgramListValue"
PropertyName
=
"Value"
DbType
=
"String"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
<
asp:ObjectDataSource
ID
=
"odsGetProgramServiceTypes"
runat
=
"server"
TypeName
=
"DMCproWebApp.BALHelper"
SelectMethod
=
"GetProgramServiceTypes"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"radgrdProgramServicesFast"
>
<
UpdatedControls
><
telerik:AjaxUpdatedControl
ControlID
=
"radgrdProgramServicesFast"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/></
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
div
class
=
"GridViewContainer"
style
=
"width:944px;"
>
<
telerik:RadGrid
ID
=
"radgrdProgramServicesFast"
runat
=
"server"
Width
=
"942px"
DataSourceID
=
"odsGetProgramServicesFast"
EnableLinqExpressions
=
"true"
EnableEmbeddedSkins
=
"false"
Skin
=
"DMCpro"
ShowStatusBar
=
"true"
AutoGenerateColumns
=
"false"
AllowFilteringByColumn
=
"false"
AllowPaging
=
"false"
AllowSorting
=
"true"
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
Selecting-AllowRowSelect
=
"true"
Scrolling-AllowScroll
=
"true"
Scrolling-ScrollHeight
=
"280px"
/>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
TableLayout
=
"Fixed"
DataKeyNames
=
"ProgramNumber,fldVenue,LineNumber,ItemNumber,OfficeLocation,ProgramLocation,ProgramStartDate,fldStatus,fldTruckLoadIn,AddToSchedule,fldAddtoContract,CustomerID,Description,RFPCount"
EditMode
=
"InPlace"
>
<
ItemStyle
Font-Size
=
"Small"
Wrap
=
"false"
/>
<
AlternatingItemStyle
Font-Size
=
"Small"
Wrap
=
"false"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"46px"
EditImageUrl
=
"~/img/Edit16x16.png"
UpdateImageUrl
=
"../img/Save16x16.png"
CancelImageUrl
=
"../img/Cancel16x16.png"
/>
<
telerik:GridImageColumn
UniqueName
=
"RFP"
ImageUrl
=
"~/img/Check-16x16.png"
HeaderText
=
"RFP"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"22px"
HeaderStyle-HorizontalAlign
=
"Left"
ItemStyle-HorizontalAlign
=
"Left"
/>
<
telerik:GridBoundColumn
DataField
=
"fldTruckLoadIn"
HeaderText
=
"Sort"
SortExpression
=
"fldTruckLoadIn"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"35px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
/>
<
telerik:GridCheckBoxColumn
DataField
=
"AddToSchedule"
HeaderText
=
"QS"
SortExpression
=
"AddToSchedule"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"25px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
/>
<
telerik:GridCheckBoxColumn
DataField
=
"fldAddToContract"
HeaderText
=
"Add"
SortExpression
=
"fldAddToContract"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"25px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"Description"
HeaderText
=
"Title"
SortExpression
=
"Description"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"135px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"Service"
UniqueName
=
"ServiceType"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"175px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "ServiceType")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"ddlProgramServiceTypes"
runat
=
"server"
Width
=
"175px"
DataSourceID
=
"odsGetProgramServiceTypes"
DataTextField
=
"fldService"
DataValueField
=
"fldServiceID"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridDropDownColumn
DataField
=
"ServiceType"
DataSourceID
=
"odsGetProgramServiceType"
HeaderText
=
"Service 2"
ListTextField
=
"fldservice"
ListValueField
=
"fldServiceID"
UniqueName
=
"Service2"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"175px"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridBoundColumn
DataField
=
"StartDate"
HeaderText
=
"Start Date"
SortExpression
=
"StartDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"75px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"EndTime"
HeaderText
=
"Ends"
SortExpression
=
"EndTime"
DataFormatString
=
"{0:MM/dd/yyyy}"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"75px"
HeaderStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"LineTotal"
HeaderText
=
"Service Total"
SortExpression
=
"LineTotal"
UniqueName
=
"LineTotal"
DataFormatString
=
"{0:c}"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"90px"
HeaderStyle-HorizontalAlign
=
"Left"
ItemStyle-HorizontalAlign
=
"Right"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"fldServiceVenue"
HeaderText
=
"Costing Sheet"
SortExpression
=
"fldServiceVenue"
UniqueName
=
"fldServiceVenue"
HeaderStyle-CssClass
=
"radGridViewHeader"
HeaderStyle-Width
=
"175px"
HeaderStyle-HorizontalAlign
=
"Left"
ItemStyle-HorizontalAlign
=
"Left"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"Cost"
Visible
=
"false"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"fldVenue"
Visible
=
"false"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"LineNumber"
Visible
=
"false"
ReadOnly
=
"true"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
div
>
Private
Sub
radgrdProgramServicesFast_ItemDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
radgrdProgramServicesFast.ItemDataBound
If
(
TypeOf
e.Item
Is
GridDataItem)
Then
Dim
gdi
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
LineTotal
As
String
= Replace(gdi.Item(
"LineTotal"
).Text,
" "
,
"0"
)
Dim
Cost
As
String
= Replace(gdi.Item(
"Cost"
).Text,
" "
,
"0"
)
Dim
chkQS
As
CheckBox =
DirectCast
(gdi.Item(
"AddToSchedule"
).Controls(0), CheckBox)
Dim
chkAdd
As
CheckBox =
DirectCast
(gdi.Item(
"fldAddToContract"
).Controls(0), CheckBox)
m_Proposed +=
CDec
(IIf(LineTotal =
String
.Empty, 0, LineTotal)) +
CDec
(IIf(Cost =
String
.Empty, 0, Cost))
m_QS +=
CDec
(IIf(chkQS.Checked, LineTotal, 0))
m_Total +=
CDec
(IIf(chkAdd.Checked, LineTotal, 0))
Dim
RFPCount
As
Integer
=
CInt
(radgrdProgramServicesFast.MasterTableView.DataKeyValues(e.Item.ItemIndex)(
"RFPCount"
))
If
(RFPCount = 0)
Then
Dim
img
As
Image =
DirectCast
(gdi.Item(
"RFP"
).Controls(0), Image)
img.Visible =
False
End
If
Dim
cp
As
ContentPlaceHolder = Page.Form.FindControl(
"MasterContentPlaceHolder"
)
Dim
status
As
Integer
=
DirectCast
(cp.FindControl(
"ddlProgramStatus"
), DropDownList).SelectedValue
If
(gdi.EditFormItem IsNot
Nothing
)
Then
If
(status <> 22)
Then
gdi.Item(
"btnEditService"
).Visible =
True
ElseIf
(status = 22)
And
Roles.IsUserInRole(Permissions.Programs_Change_Sold_Invoiced)
Then
gdi.Item(
"btnEditService"
).Visible =
True
Else
gdi.Item(
"btnEditService"
).Visible =
False
End
If
End
If
End
If
End
Sub