ASP.NET 3.5 DataGrid Edit using FCKEditor?

I am a total newbie to ASP.net, and finally figured out how to setup my datagrid to allow editing, and then finally figured out how to add an edit item template to create a text box to allow editing of a large 'text' column in our SQL database.

Now, I would like to use FCKEditor to edit that TEXT column.
See in the code snip below the <!--commented out--> textbox field - this works.
See the non commented FCKEditor field - when I click the UPDATE link in my datagrid, it simply writes a blank value back to the column in the database, even though, when clicking the EDIT link in the datagrid, the original value from the text column is populated into the FCKEditor control.

Anyone done this before?
<EditItemTemplate>
			<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" BasePath="~/fckeditor/" Value='<%# Bind("Description")%>' Width="400">
			</FCKeditorV2:FCKeditor>
                   <!--<asp:TextBox  Rows="5" columns="50" TextMode=MultiLine ID="TextBox1" runat="server" Text='<%# Bind("Description")%>'></asp:TextBox>-->
                   </EditItemTemplate></asp:TemplateField>

Open in new window

jn1480Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

prairiedogCommented:
What event handler are you using to update the record?
0
jn1480Author Commented:
Sorry prairiedog - total newbie - I am just using the default GridView control.
 I'm an old ASP3'er, so if you'd be willing to show me the manual - non-control way of doing this I'd be game!

/edit/default2.aspx page: 
 
    <p>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="dsProducts">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                    ShowSelectButton="True" />
                <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                    SortExpression="ID" />
                <asp:BoundField DataField="Item" HeaderText="Item" SortExpression="Item" />
                <asp:BoundField DataField="Description" Visible="False" HeaderText="Item" SortExpression="Description" />
                <asp:BoundField DataField="Price_Low" HeaderText="Price_Low" 
                    SortExpression="Price_Low" />
                <asp:BoundField DataField="Price_High" HeaderText="Price_High" 
                    SortExpression="Price_High" />
                <asp:BoundField DataField="Picture" HeaderText="Picture" 
                    SortExpression="Picture" />
                    <asp:TemplateField>
                    <ItemTemplate>
                    
                    </ItemTemplate>
                    <EditItemTemplate>
			<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" BasePath="~/fckeditor/" Value='<%# Bind("Description")%>' Width="400">
			</FCKeditorV2:FCKeditor>
                   <!--<asp:TextBox  Rows="5" columns="50" TextMode=MultiLine ID="TextBox1" runat="server" Text='<%# Bind("Description")%>'></asp:TextBox>-->
                   </EditItemTemplate></asp:TemplateField>
            </Columns>
        </asp:GridView>
    </p>
    <p>
        
        
        
        <asp:SqlDataSource ID="dsProducts" runat="server" 
            ConnectionString="<%$ ConnectionStrings:csServer %>" 
            SelectCommand="SELECT * FROM [Products]" 
            DeleteCommand="DELETE FROM [Products] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [Products] ([Item], [Description], [Price_Low], [Price_High], [Picture]) VALUES (@Item, @Description, @Price_Low, @Price_High, @Picture)" 
            UpdateCommand="UPDATE [Products] SET [Item] = @Item, [Description] = @Description, [Price_Low] = @Price_Low, [Price_High] = @Price_High, [Picture] = @Picture WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Byte" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Item" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Price_Low" Type="Int32" />
                <asp:Parameter Name="Price_High" Type="Int32" />
                <asp:Parameter Name="Picture" Type="String" />
                <asp:Parameter Name="ID" Type="Byte" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Item" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="Price_Low" Type="Int32" />
                <asp:Parameter Name="Price_High" Type="Int32" />
                <asp:Parameter Name="Picture" Type="String" />
            </InsertParameters>
            </asp:SqlDataSource>
    </p>

Open in new window

0
prairiedogCommented:
1. Uncomment FCKeditor
2. Add this RowUpdating event handler in your code-behind:
 

Private Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
	Dim row As GridViewRow = Me.GridView1.Rows(e.RowIndex)
	Dim ftxtDescription As FredCK.FCKeditorV2.FCKeditor = CType(row.FindControl("FCKeditor1"), FredCK.FCKeditorV2.FCKeditor)
	Me.SqlDataSource1.UpdateParameters("Description").DefaultValue = ftxtDescription.Value
	Me.SqlDataSource1.Update()
	Me.GridView1.DataBind()
 
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jn1480Author Commented:
Thanks for the note prairiedog! I am still a bit too early on in my Beginning ASP.NET 3.5 book to fully understand what you are saying here. However, in my quick scanning of the upcoming chapters on database access/etc I do see some notes to this effect, so it gives me hope!
In the mean time, I got it to work using the apparently(?) more appropriate DetailsView control? (see code snippet)
That worked out just fine!

    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" 
        AllowPaging="True" AutoGenerateRows="False" DataKeyNames="ID" 
        DataSourceID="dsDatabase">
        
        <Fields>
            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" 
                SortExpression="ID" />
            <asp:BoundField DataField="Item" HeaderText="Item" SortExpression="Item" />
            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                <EditItemTemplate>
                    <FCKeditorV2:FCKeditor ID="TextBox1" runat="server" BasePath="~/fckeditor/" Value='<%# Bind("Description") %>' Height="200" Width="500">
			</FCKeditorV2:FCKeditor>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Price_High" HeaderText="Price_High" 
                SortExpression="Price_High" />
            <asp:BoundField DataField="Price_Low" HeaderText="Price_Low" 
                SortExpression="Price_Low" />
            <asp:BoundField DataField="Picture" HeaderText="Picture" 
                SortExpression="Picture" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="dsDatabase" runat="server" 
        ConnectionString="<%$ ConnectionStrings:csLocal %>" 
        DeleteCommand="DELETE FROM [Products] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [Products] ([Item], [Description], [Price_High], [Price_Low], [Picture]) VALUES (@Item, @Description, @Price_High, @Price_Low, @Picture)" 
        SelectCommand="SELECT [ID], [Item], [Description], [Price_High], [Price_Low], [Picture] FROM [Products]" 
        UpdateCommand="UPDATE [Products] SET [Item] = @Item, [Description] = @Description, [Price_High] = @Price_High, [Price_Low] = @Price_Low, [Picture] = @Picture WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Byte" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Item" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Price_High" Type="Int32" />
            <asp:Parameter Name="Price_Low" Type="Int32" />
            <asp:Parameter Name="Picture" Type="String" />
            <asp:Parameter Name="ID" Type="Byte" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Item" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Price_High" Type="Int32" />
            <asp:Parameter Name="Price_Low" Type="Int32" />
            <asp:Parameter Name="Picture" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

Open in new window

0
prairiedogCommented:
Cool. Glad you got it worked out, though through a different approach from your original one.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.