I'm trying to integrate FCKeditor into a GridView control in order to insert/edit new records. I will eventually use a DetailsView for inserting/editing but for now I just need to modify some existing code.
The existing GridView code:
<asp:TemplateField HeaderText="Product Description" SortExpression="Description">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
Height="100px" Width="97%" CssClass="GridEditingRow" TextMode="MultiLine" />
</EditItemTemplate>
</asp:TemplateField>
Code behind:
string description = ((TextBox)grid.Rows[e.RowIndex].FindControl("descriptionTextBox")).Text;
My new GridView code:
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Description" SortExpression="Description">
<ItemTemplate>
<asp:Label ID="LabelDescription" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<FCKeditorV2:FCKeditor ID="FCKeDescription" Height="100" Value='<%# Bind("Description") %>'
runat="server">
</FCKeditorV2:FCKeditor>
</EditItemTemplate>
</asp:TemplateField>
My attempts at code behind:
Attempt #1:
string description = (grid.Rows[e.RowIndex].FindControl("FCKeDescription.")).ToString();
Attempt #1 result: simply inserts "FredCK.FCKeditorV2.FCKeditor" into the description field in the database
Attempt #2:
string description = (grid.Rows[e.RowIndex].FindControl("FCKeDescription.Value")).ToString();
Attempt #2 result: throws the error "System.NullReferenceException: Object reference not set to an instance of an object.
Attempt #3:
string description = (grid.Rows[e.RowIndex].FindControl(FCKeDescription.Value)).ToString();
Attempt #1 result: thows the error "The name 'FCKeDescription' does not exist in the current context"
Attempt #4:
string fCKeDescription = FCKeDescription.Value.ToString();
protected void grid_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string description = (grid.Rows[e.RowIndex].FindControl("fCKeDescription")).ToString();
}
Attempt #4 result: thows the error "The name 'FCKeDescription' does not exist in the current context"
The existing GridView code:
<asp:TemplateField HeaderText="Product Description" SortExpression="Description">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
Height="100px" Width="97%" CssClass="GridEditingRow" TextMode="MultiLine" />
</EditItemTemplate>
</asp:TemplateField>
Code behind:
string description = ((TextBox)grid.Rows[e.RowIndex].FindControl("descriptionTextBox")).Text;
My new GridView code:
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Description" SortExpression="Description">
<ItemTemplate>
<asp:Label ID="LabelDescription" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<FCKeditorV2:FCKeditor ID="FCKeDescription" Height="100" Value='<%# Bind("Description") %>'
runat="server">
</FCKeditorV2:FCKeditor>
</EditItemTemplate>
</asp:TemplateField>
My attempts at code behind:
Attempt #1:
string description = (grid.Rows[e.RowIndex].FindControl("FCKeDescription.")).ToString();
Attempt #1 result: simply inserts "FredCK.FCKeditorV2.FCKeditor" into the description field in the database
Attempt #2:
string description = (grid.Rows[e.RowIndex].FindControl("FCKeDescription.Value")).ToString();
Attempt #2 result: throws the error "System.NullReferenceException: Object reference not set to an instance of an object.
Attempt #3:
string description = (grid.Rows[e.RowIndex].FindControl(FCKeDescription.Value)).ToString();
Attempt #1 result: thows the error "The name 'FCKeDescription' does not exist in the current context"
Attempt #4:
string fCKeDescription = FCKeDescription.Value.ToString();
protected void grid_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string description = (grid.Rows[e.RowIndex].FindControl("fCKeDescription")).ToString();
}
Attempt #4 result: thows the error "The name 'FCKeDescription' does not exist in the current context"

Re: FCKeditor in GridView control: insert/update