This is a migrated thread and some comments may be shown as answers.

Editing labels inside grid

1 Answer 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sudhakar
Top achievements
Rank 1
Sudhakar asked on 28 Oct 2014, 02:21 PM
Hi Team,

I am using telerik version of

I have a grid inside that grid I have three tabs.In one tab click I am displaying the labels with some data.
I need to edit that labels.
Is it possible to edit the labels inside the grid.

aspx file:

<telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="375px"
                            Width="500px" OnNeedDataSource="LoadingRadGrid_NeedDataSource"
                             OnUpdateCommand="LoadingRadGrid_UpdateCommand" OnBatchEditCommand="LoadingRadGrid_BatchEditCommand" OnInsertCommand="LoadingRadGrid_InsertCommand"
                             OnItemCommand="LoadingRadGrid_ItemCommand" OnSelectedIndexChanged="LoadingRadGrid_SelectedIndexChanged" OnCancelCommand="LoadingRadGrid_CancelCommand">
                              
                            <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Loading_ID">
                                <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewLoad" />
                            <BatchEditingSettings EditType="Cell" />
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage" ClickSelectedTab="True"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                            <div class="contactWrap">
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                       <td><asp:Label ID="lbl_TerminalId" runat="server" Text='Terminal Id:' Font-Bold="true"></asp:Label></td>
                                                       <td><asp:Label ID="lbl_TerminalIdValue" runat="server"></asp:Label> </td> 
                                                    </tr>
                                                    <tr>
                                                        <td><asp:Label ID="lbl_TerminalName" runat="server" Text='TerminalName:' Font-Bold="true"></asp:Label></td>
                                                        <td><asp:Label ID="lbl_TerminalNameValue" runat="server"></asp:Label> </td>
                                                       
                                                    </tr>
                                                </table>
                                            </div>
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="CompartmentLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="CompartmentLevelLoadRadGrid_ItemDataBound" OnNeedDataSource="CompartmentLevelLoadingRadGrid_NeedDataSource"
                                                OnUpdateCommand="CompartmentLevelLoadRadGrid_UpdateCommand" OnBatchEditCommand="CompartmentLevelLoadRadGrid_BatchEditCommand" OnInsertCommand="CompartmentLevelLoadRadGrid_InsertCommand">
                                                <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch">
                                                     <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add Line Item"/>
                                                     <BatchEditingSettings EditType="Cell" />                                              
                                                    <Columns>
                                                   
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex" HeaderText="Comp No." ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PriorToLoad" DataField="PTL" HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Actual Product" >
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                                       
                                            <telerik:RadGrid ID="ProductLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="ProductLevelLoadRadGrid_ItemDataBound" OnNeedDataSource="ProductLevelLoadingRadGrid_NeedDataSource">
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                                        </telerik:GridBoundColumn>                                                    
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Product">
                                                        </telerik:GridBoundColumn>                                                       
                                                        <telerik:GridBoundColumn  UniqueName="PriorToLoadQty" DataField="PTL"  HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID" ReadOnly="true">                                       
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">                                           
                                            <RequiredFieldValidator ForeColor="Red" Text="Plant_ID is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                   
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>

aspx.cs file:


protected void LoadTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
        //AddPageView(e.Tab.Text);
        e.Tab.PageView.Selected = true;
        string selectedtabindex = e.Tab.Text;
        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        Int64 load = 0;
        load = Convert.ToInt64(Session[_lastLoadingSelect1].ToString());
        switch (selectedtabindex)
        {
            case "Details":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    List<LoadingDetailExtraEntity> loadingDetails = new List<LoadingDetailExtraEntity>();
                    //loadingDetails = loadingDetailManager.GetLoadingDetailByShipmentId(shipmentID);
                    loadingDetails = loadingDetailManager.GetLoadingDetailWSListByLoadingId(load);
                    Label lblTerminalId = (Label)page.FindControl("lbl_TerminalIdValue");
                    Label lblTerminalName = (Label)page.FindControl("lbl_TerminalNameValue");
                    if (loadingDetails.Count > 0)
                    {
                       
                        lblTerminalId.Text = loadingDetails[0].Plant_ID.ToString();                       
                        lblTerminalName.Text = loadingDetails[0].TerminalName;
                    }
                    else
                    {
                        lblTerminalId.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        lblTerminalName.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                    }
                    break;
                }
            case "Compartments":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdCompartment = (RadGrid)page.FindControl("CompartmentLevelLoadRadGrid");                    //List<LoadingDetailExtraEntity> CompartmentTabListinstance = new List<LoadingDetailExtraEntity>();
                    //CompartmentTabListinstance = loadingDetailManager.GetLoadingDetailWSListByLoadingId(load);
                    //Session["_storeCompartmentLoadTable"] = CompartmentTabListinstance;                    List<LoadingDetailExtraEntity> CompartmentTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeCompartmentLoadTable"];                    grdCompartment.DataSource = CompartmentTabListinstance;
                    grdCompartment.DataBind();                    //e.Tab.Controls.Add(grdLoad);
                    break;
                }
            case "Products":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdProduct = (RadGrid)page.FindControl("ProductLevelLoadRadGrid");
                    //List<LoadingDetailExtraEntity> ProductTabListinstance = new List<LoadingDetailExtraEntity>();
                    //ProductTabListinstance = loadingDetailManager.GetLoadingDetailByLoadIdAtProductLevel(load);
                    //Session["_storeProductLoadTable"] = ProductTabListinstance;                    List<LoadingDetailExtraEntity> ProductTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeProductLoadTable"];
                    grdProduct.DataSource = ProductTabListinstance;
                    grdProduct.DataBind();
                    break;
                }
        }
    }



‚Äč

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 31 Oct 2014, 09:31 AM
Hello Sudhakar,

Note that the Label controls are used to display information. They do not provide an option for the user to edit the data. In order to edit the information you could replace the lbl_TerminalIdValue and lbl_TerminalNameValue with TextBox controls. Also you could add a button that will be used to save the data. The markup for the RadPageView would look similar to the following:

<telerik:RadPageView runat="server" ID="RadPageViewDetails">
    <div class="contactWrap">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <asp:Label ID="lbl_TerminalId" runat="server" Text='Terminal Id:' Font-Bold="true"></asp:Label></td>
                <td>
                    <asp:TextBox ID="txtBox_TerminalIdValue" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbl_TerminalName" runat="server" Text='TerminalName:' Font-Bold="true"></asp:Label></td>
                <td>
                    <asp:TextBox ID="txtBox_TerminalNameValue" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button runat="server" Text="Save" ID="ButtonSave" OnClick="ButtonSave_Click" />
                </td>
            </tr>
        </table>
    </div>
</telerik:RadPageView>

In order to populate the initial values for the TextBox controls you can use the same approach as the one you have implemented for setting the Text for the Labels. In order to save the new data to the data source you could use the Click event handler for the Button.


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Sudhakar
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or