Rich Text Editor in a DetailsView

Last post 05-19-2008 2:27 AM by Samu Zhang - MSFT. 2 replies.

Sort Posts:

  • Rich Text Editor in a DetailsView

    05-16-2008, 2:04 PM
    • Loading...
    • Wilbo
    • Joined on 04-18-2008, 8:04 PM
    • Posts 59

    Im using a RichTextBox in a detailsView, but Im having trouble databinding it.

    (I want to use it to enter some text into a database).

    When I click on databinding, it only lists 'visible' as the properties that can be bound to the fields in the database.

    Obviously if I bind to this it just enters the word 'true' into my database.

    The question is, how do I set it up to so that it enters the text I type in into my database?

     

    Thanks in advance

  • Re: Rich Text Editor in a DetailsView

    05-17-2008, 6:11 AM
    • Loading...
    • aamador
    • Joined on 02-11-2008, 10:49 PM
    • Posts 1,105

    post some code

     

    I am not anti social, am just not user friendly
  • Re: Rich Text Editor in a DetailsView

    05-19-2008, 2:27 AM
    Answer

    Hi Wilbo ,

    Here is my sample.

    I download this custom control from here : http://www.codeproject.com/KB/aspnet/RichTextBox.aspx

    Here is my code:

     

        <form id="form1" runat="server">
        <div>
            <asp:DetailsView DefaultMode="Insert" ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="countryid"
                DataSourceID="SqlDataSource1" Height="50px" Width="125px">
                <Fields>
                    <asp:TemplateField HeaderText="countryid" SortExpression="countryid">
                        <EditItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("countryid") %>'></asp:Label>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("countryid") %>'></asp:TextBox>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("countryid") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="countryname" SortExpression="countryname">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("countryname") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            
                            <cc1:VKRichTextBox ID="VKRichTextBox1" runat="server"  Text='<%# Bind("countryname") %>'/>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("countryname") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowInsertButton="True" />
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
                DeleteCommand="DELETE FROM [country] WHERE [countryid] = @countryid" InsertCommand="INSERT INTO [country] ([countryid], [countryname]) VALUES (@countryid, @countryname)"
                SelectCommand="SELECT * FROM [country]" UpdateCommand="UPDATE [country] SET [countryname] = @countryname WHERE [countryid] = @countryid">
                <DeleteParameters>
                    <asp:Parameter Name="countryid" Type="Int64" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="countryname" Type="String" />
                    <asp:Parameter Name="countryid" Type="Int64" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="countryid" Type="Int64" />
                    <asp:Parameter Name="countryname" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
        
        </div>
        </form>
     
    Sincerely,
    Samu Zhang
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter