Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Textarea in inline edit

Answered Textarea in inline edit

Feed from this thread
  • Sam avatar

    Posted on Feb 7, 2012 (permalink)

    I need to change the default small textbox to a textarea in edit mode ( inline) and it's not working, the textarea shows up when i use a template column but when it tries to update the textarea value it throws an error because it cannot find the value even though I set up Update params in the SQL datasource. Is there any sample projects that do this? I am wondering if it cannot find the value because I am using master pages.

    Here is the code for the grid:

    <telerik:RadGrid ID="rgNews" runat="server" CellSpacing="0"
                        DataSourceID="sdsNews" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" GridLines="None" AllowPaging="True"
                        AllowSorting="True" AutoGenerateColumns="False">
                        <ClientSettings>
                            <Selecting AllowRowSelect="True" />
                        </ClientSettings>
    <MasterTableView DataKeyNames="newsID" CommandItemDisplay="Top" AllowAutomaticInserts="true" DataSourceID="sdsNews">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
     
        <Columns>
            <telerik:GridBoundColumn DataField="newsID" DataType="System.Int32"
                FilterControlAltText="Filter newsID column" HeaderText="newsID"
                ReadOnly="True" SortExpression="newsID" UniqueName="newsID"
                Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelText=""
                FilterControlAltText="Filter EditCommandColumn column"
                UpdateText="">
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="Title"
                FilterControlAltText="Filter Title column" HeaderText="Title"
                SortExpression="Title" UniqueName="Title">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Date"
                FilterControlAltText="Filter Date column" HeaderText="Date"
                SortExpression="Date" UniqueName="Date">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Author"
                FilterControlAltText="Filter Author column" HeaderText="Author"
                SortExpression="Author" UniqueName="Author">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Publication"
                FilterControlAltText="Filter Publication column" HeaderText="Publication"
                SortExpression="Publication" UniqueName="Publication">
            </telerik:GridBoundColumn>
           <%-- <telerik:GridBoundColumn DataField="Content"
                FilterControlAltText="Filter Content column" HeaderText="Content"  Visible="False"
                SortExpression="Content" UniqueName="Content">
            </telerik:GridBoundColumn>--%>
            <telerik:GridTemplateColumn UniqueName="Content" DataField="Content"  HeaderText="Content" Visible="false">
            <ItemTemplate>
            <asp:Label ID="lblContent" Text='<%# Bind("Content") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
            <asp:TextBox ID="txtContent" TextMode="MultiLine" Text='<%# Eval("Content") %>' Height="150" Width="200" runat="server"></asp:TextBox>
            </EditItemTemplate>
            </telerik:GridTemplateColumn>
             <telerik:GridBoundColumn DataField="Link"
                FilterControlAltText="Filter Link column" HeaderText="Link"
                SortExpression="Link" Visible="false" UniqueName="Link">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ButtonType="ImageButton"
          UniqueName= "DeleteColumn" />
        </Columns>
     
    <EditFormSettings CaptionFormatString="Edit news details for {0}" FormCaptionStyle-Font-Bold="true" FormCaptionStyle-ForeColor="#9d273f" CaptionDataField="Title">
    <EditColumn FilterControlAltText="Filter EditCommandColumn column" ButtonType="ImageButton"></EditColumn>
    </EditFormSettings>
    </MasterTableView>
     
    <FilterMenu EnableImageSprites="False"></FilterMenu>
     
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
                    </telerik:RadGrid>

    Here is the SQL Datasource code:

    <asp:SqlDataSource ID="sdsNews" runat="server"
           ConnectionString="<%$ ConnectionStrings:CLSWEBConnectionString %>"     
           SelectCommand="SELECT [newsID], [Title], [Date], [Author], [Publication], [Content], [Link] FROM [tblNews]"
           UpdateCommand="UPDATE [tblNews] set [Title] = @Title, [Date] = @Date, [Author] = @Author, [Publication] = @Publication, [Content] = @Content, [Link] = @Link WHERE [newsID] = @newsID"
           DeleteCommand="DELETE FROM [tblNews] WHERE [newsID] = @newsID">
           <UpdateParameters>
           <asp:Parameter Name="Content" Type="String" />
           </UpdateParameters>
       </asp:SqlDataSource>



    Here is the error it throws, I am guessing it cannot find the value of the Content template column:

    Cannot insert the value NULL into column 'Content', table 'CLSWEB.dbo.tblNews'; column does not allow nulls. UPDATE fails.
    The statement has been terminated.






    Thanks,
    Sam

    Reply

  • Answer Shinu MVP avatar

    Posted on Feb 7, 2012 (permalink)

    Hello Sam,

    I tried the same scenario which worked as expected in my end. Check the following demo which implements the same.
    Grid / Automatic Operations

    -Shinu.

    Reply

  • Sam avatar

    Posted on Feb 8, 2012 (permalink)

    I got it to work, apparently you need to use a <telerik:RadTextBox for it to pick up the value........... Is there an easy way to set the width of the textboxes in edit mode? I saw a method suggested in the forums from a post 2 years ago and it looks like an unnecessary hassle to set something that should be exposed in the markup.

    Reply

  • Answer Shinu MVP avatar

    Posted on Feb 9, 2012 (permalink)

    Hello Sam,

    You cannot change the width of RadTextBox in mark up. Try the following code to access RadTextBox in edit mode and set the width accordingly.
    c#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
     if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
     {
      GridEditableItem item = (GridEditableItem)e.Item;  
      RadTextBox radtextbox1 = (RadTextBox)item.FindControl("RadTextBox1");                       
      radtextbox1.Width = Unit.Pixel(30);
     }
    }

    -Shinu.

    Reply

  • Sam avatar

    Posted on Feb 9, 2012 (permalink)

    Thanks for the info. That seems like a HUGE miss on Telerik's end...... width should be set in markup.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Textarea in inline edit
Related resources for "Textarea in inline edit"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]