locked
Telerik GridBoundColumn Multiline RRS feed

  • Question

  • User-120165138 posted

    Does anyone know how I can set a Telerik GridBoundColumn to a multiline textbox? I want to set my description column to multiline. Im really new to telerik, and asp.net itself. Any help would be great.

    Thanks


    <%@ Page Title="" Language="C#" MasterPageFile="~/NestedMasterPageTemplate.master"
        AutoEventWireup="true" CodeFile="Programs.aspx.cs" Inherits="Study_Abroad_Programs" %>
    
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="divMsg" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div id="divMsg" runat="server" style="float: left;">
            <asp:Label ID="Label1" runat="server" EnableViewState="False" Visible="false"></asp:Label>
        </div>
        <telerik:RadGrid ID="RadGrid1" AllowAutomaticInserts="true" runat="server" DataSourceID="SqlDataSource1"
            AutoGenerateColumns="false" Width="700">
            <MasterTableView DataKeyNames="ProgramID">
                <Columns>
                    <telerik:GridBoundColumn DataField="ProgramName" Resizable="true" HeaderText="Program Name"
                        EditFormColumnIndex="0">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Institution" DataField="Institution" EditFormColumnIndex="0">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="StartDate" HeaderText="Start Date" Visible="false"
                        EditFormColumnIndex="0">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridDateTimeColumn DataField="EndDate" HeaderText="End Date" Visible="false"
                        EditFormColumnIndex="0">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn HeaderText="Country" DataField="Country" EditFormColumnIndex="0">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="City" DataField="City">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn HeaderText="On Campus Housing" DataField="OnCampusHousing"
                        Visible="false">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridDropDownColumn HeaderText="Housing Type" DataField="HousingType" ListTextField="HousingType"
                        ListValueField="HousingType" DataSourceID="SqlDataSource2" Visible="false">
                    </telerik:GridDropDownColumn>
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                    </telerik:GridEditCommandColumn>
                </Columns>
                <EditFormSettings ColumnNumber="3" CaptionFormatString="Edit details for Program {0}"
                    CaptionDataField="ProgramName">
                    <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" />
                    <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" CssClass="module"
                        Height="110px" Width="100%" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle>
                    <EditColumn UpdateText="Update" UniqueName="EditCommandColumn1" CancelText="Cancel">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Left" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
                <EditItemTemplate>
                </EditItemTemplate>
    
            </MasterTableView>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MIS5050DBConnectionString_General %>"
            DeleteCommand="DELETE FROM [SAPrograms] WHERE [ProgramID] = @ProgramID" InsertCommand="INSERT INTO [SAPrograms] ( [ProgramName], [Description], [StartDate], [EndDate], [OnCampusHousing], [HousingType], [CreateDate], [ModDate], [Country], [City], [PostalCode], [Institution]) VALUES ( @ProgramName, @Description, @StartDate, @EndDate,  @OnCampusHousing, @HousingType, @CreateDate, @ModDate, @Country, @City, @PostalCode, @Institution)"
            SelectCommand="SELECT [ProgramID]
          ,[ProgramName]
          ,[Description]
          ,[StartDate]
          ,[EndDate]
          ,[OnCampusHousing]
          ,[HousingType]
          ,[CreateDate]
          ,[ModDate]
          ,[Country]
          ,[City]
          ,[PostalCode]
          ,[Institution]
      FROM [MIS5050DB].[dbo].[SAPrograms]" UpdateCommand="UPDATE [SAPrograms] SET [ProgramName] = @ProgramName, [Description] = @Description, [StartDate] = @StartDate, [EndDate] = @EndDate, [OnCampusHousing] = @OnCampusHousing, [HousingType] = @HousingType, [CreateDate] = @CreateDate, [ModDate] = @ModDate, [Country] = @Country, [City] = @City, [PostalCode] = @PostalCode, [Institution] = @Institution WHERE [ProgramID] = @ProgramID">
            <DeleteParameters>
                <asp:Parameter Name="ProgramID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ProgramName" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="OnCampusHousing" Type="String" />
                <asp:Parameter Name="HousingType" Type="String" />
                <asp:Parameter Name="CreateDate" Type="DateTime" />
                <asp:Parameter Name="ModDate" Type="DateTime" />
                <asp:Parameter Name="Country" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="PostalCode" Type="String" />
                <asp:Parameter Name="Institution" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="ProgramName" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="OnCampusHousing" Type="String" />
                <asp:Parameter Name="HousingType" Type="String" />
                <asp:Parameter Name="CreateDate" Type="DateTime" />
                <asp:Parameter Name="ModDate" Type="DateTime" />
                <asp:Parameter Name="Country" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="PostalCode" Type="String" />
                <asp:Parameter Name="Institution" Type="String" />
                <asp:Parameter Name="ProgramID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MIS5050DBConnectionString_General %>"
            SelectCommand="SELECT DISTINCT [HousingType] FROM [SAPrograms] ORDER BY [HousingType]">
        </asp:SqlDataSource>
    </asp:Content>
    



    Monday, November 15, 2010 12:22 AM

Answers

  • User-120165138 posted

    Thanks for the reply,

    I ended up using a GridTemplateColumn to add multiline. Is there any benifit to using one code or the other?

    ~Curt


                    <telerik:GridTemplateColumn UniqueName="Description" DataField="Description" HeaderText="Description"
                        Visible="false">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" Text='<%# Bind( "Description") %>' Columns="30" Rows="5"
                                TextMode="MultiLine" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 18, 2010 10:44 AM

All replies

  • User-1227788583 posted

    Hi wheel0513,

    Wrong place to ask really.

    Telerik guys have a wonderful forum: Click Here


    Monday, November 15, 2010 1:25 AM
  • User1525433465 posted

    Hello,


    Yea, it is possible to set the textboxes in EditForm as MultiLine by accessing the control when in EditMode and setting the property from code behind. A sample code is here:

    C#:

        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
            { 
                GridEditFormItem editItem = (GridEditFormItem)e.Item; 
                TextBox textBox = (TextBox)editItem["columnUniqueName"].Controls[0]; 
                textBox.TextMode = TextBoxMode.MultiLine; 
            } 
        } 


    The same is shown here in Telerik forum:

    textareas rather than textboxes



    -Shinu.

    Thursday, November 18, 2010 5:48 AM
  • User-120165138 posted

    Thanks for the reply,

    I ended up using a GridTemplateColumn to add multiline. Is there any benifit to using one code or the other?

    ~Curt


                    <telerik:GridTemplateColumn UniqueName="Description" DataField="Description" HeaderText="Description"
                        Visible="false">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" Text='<%# Bind( "Description") %>' Columns="30" Rows="5"
                                TextMode="MultiLine" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 18, 2010 10:44 AM