This is a migrated thread and some comments may be shown as answers.
edit the textbox inside the tab
2 Answers 15 Views
This is a migrated thread and some comments may be shown as answers.
Sudhakar
Top achievements
Rank 1
Sudhakar asked on 04 Nov 2014, 02:34 PM
Hi Team,

I have a grid with some rows in it.When I expand each row I am displaying three tabs in it.
On click of on of the tabs(detail tab in the aspx file) I am loading the data in to the textboxes.
I wanted to edit this textboxes after the data is loaded in to the textboxes.ASPX FILE:<telerik:RadGrid ID="DischargeRadGrid"   OnItemDataBound="DsichargeRadGridFormat_OnItemDataBound" runat="server" AutoGenerateColumns="false"
                            CssClass="TransferGridPanel" Height="370px" Width="500px" OnItemCommand="DischargeRadGrid_ItemCommand"
                            OnBatchEditCommand="DischargeRadGrid_BatchEditCommand">
                           <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Discharge_ID">
                            <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewDelivery" />
                               <BatchEditingSettings EditType="Cell" />
                            <NestedViewTemplate>
                             <telerik:RadTabStrip runat="server" ID="DischargeTabStrip" MultiPageID="DischargeMultipage" ClickSelectedTab="True"
                                 SelectedIndex="0" OnTabClick="DischargeTabStip_TabClick">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Details" PageViewID="DischargePageViewDetails">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="DischargePageViewCompartments">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Products" PageViewID="DischargePageViewProducts">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage runat="server" ID="DischargeMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="DischargePageViewDetails">
                            <div class="contactWrap">
                                <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_ShipTo" Text='ShipTo:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_ShipToValue" Enabled="false"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_SiteName" Text='Name:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_SiteNameValue" Enabled="false"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_Address" Text='Address:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_AddressValue" Enabled="false" TextMode="MultiLine"></asp:TextBox></td>
                                    </tr>                                    <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_SplInstruction" Text='SpecialInstructions:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_SplInstructionValue" Enabled="false"></asp:TextBox></td>
                                    </tr>                                    <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_PONumber" Text='PONumber:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_PONumberValue"  Enabled="false"></asp:TextBox>
                                            <asp:ImageButton ImageUrl="~/images/PenEditIcon.gif" runat="server" ID="btn_editPONumber"  OnClick="btn_editPONumber_Click"></asp:ImageButton>                                    </td>
                                </tr>
                                 
                                   
                            </table>
                            </div>
                        </telerik:RadPageView>
                        <telerik:RadPageView runat="server" ID="DischargePageViewCompartments">
                            <telerik:RadGrid ID="CompartmentLevelDischargeRadGrid" runat="server" AutoGenerateColumns="false"
                                CssClass="TransferGridPanel" Height="233px" Width="475px" OnItemDataBound="CompartmentLevelDischargeRadGrid_ItemDataBound">
                                <MasterTableView ShowHeadersWhenNoRecords="true">
                                    <Columns>
                                        <telerik:GridBoundColumn UniqueName="ItemNo" DataField="CompartmentIndex" HeaderText="Comp No.">
                                        </telerik:GridBoundColumn>
                                       
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeProd" DataField="PlannedProductName" HeaderText="Planned Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeProd" DataField="ActualProductName" HeaderText="Actual Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedTank" DataField="TankIndex" HeaderText="Planned Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualTank" DataField="ActualTankIndex" HeaderText="Actual Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="LeftOnBoard" DataField="LOB" HeaderText="LOB">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="Adjustment" DataField="Adjustment" HeaderText="Adjustment">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadPageView>
                    <telerik:RadPageView runat="server" ID="DischargePageViewProducts">
                    <telerik:RadGrid ID="ProductLevelDischargeRadGrid" runat="server" AutoGenerateColumns="false"
                                CssClass="TransferGridPanel" Height="233px" Width="475px" OnItemDataBound="ProductLevelDischargeRadGrid_ItemDataBound">
                            <MasterTableView ShowHeadersWhenNoRecords="true">
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="PlannedDischargeProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                        </telerik:GridBoundColumn>                                       
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeProd" DataField="ActualProductName" HeaderText="Actual Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                        </telerik:GridBoundColumn>                                       
                                        <telerik:GridBoundColumn UniqueName="ActualTank" DataField="ActualTankIndex" HeaderText="Actual Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="CaluculatedDifference" DataField="CaluculatedDifference" HeaderText="Caluculated Difference">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PreDip" DataField="PreDip" HeaderText="PreDip">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PostDip" DataField="PostDip" HeaderText="PostDip">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PreSMR" DataField="PreSMR" HeaderText="SMR Start">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PostSMR" DataField="PostSMR" HeaderText="SMR End">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="LeftOnBoard" DataField="LOB" HeaderText="LOB">
                                    </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="Adjustment" DataField="Adjustment" HeaderText="Adjustment">
                                    </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                    </telerik:RadPageView>
                    </telerik:RadMultiPage>
                    </NestedViewTemplate>                                <Columns>
                                    <telerik:GridBoundColumn  UniqueName="DeliveryNo" DataField="Discharge_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipTo"
                                        DataField="Site_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipToName"
                                        DataField="SiteAddress" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeStart"
                                        DataField="DischargeStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeEnd"
                                        DataField="DischargeEndTime">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>                           
                           
                            <Scrolling AllowScroll="true"/></ClientSettings>
                        </telerik:RadGrid>ASPX.CS FILEprotected void DischargeTabStip_TabClick(object sender, RadTabStripEventArgs e)
 {
 //AddPageView(e.Tab.Text);
e.Tab.PageView.Selected = true;
 string selectedtabindex = e.Tab.Text;
 Session["tabindex"] = e.Tab.Text;
 Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
 //Int64 load = 0;
 //load = Convert.ToInt64(Session[_lastLoadingSelect1].ToString());
 Int64 discharge = 0;
 discharge = Convert.ToInt64(Session[_lastDischargeSelect1].ToString());
 switch (selectedtabindex)
 {
 case "Details":
 {
RadPageView page = (RadPageView)e.Tab.PageView;
ImageButton btneditPONumber = (ImageButton)page.FindControl("btn_editPONumber");
btneditPONumber.Click += new System.Web.UI.ImageClickEventHandler(btn_editPONumber_Click);  List<DischargeEntity> dischargeDetails = new List<DischargeEntity>();
dischargeDetails = dischargeManager.GetDischargeDetailsByDischargeId(discharge);//.GetDischargeByID(discharge);
 Session[_sesDischargeList] = dischargeDetails;
 //Label lblShipTo = (Label)page.FindControl("lbl_ShipToValue");
 //Label lblSiteName = (Label)page.FindControl("lbl_SiteNameValue");
 //Label lblAddress = (Label)page.FindControl("lbl_AddressValue");
 //Label lblSplInstructions = (Label)page.FindControl("lbl_SplInstructionValue");
 //Label lblPONumber = (Label)page.FindControl("lbl_PONumberValue");TextBox txtShipTo = (TextBox)page.FindControl("txt_ShipToValue");
TextBox txtSiteName = (TextBox)page.FindControl("txt_SiteNameValue");
TextBox txtAddress = (TextBox)page.FindControl("txt_AddressValue");
TextBox txtSplInstructions = (TextBox)page.FindControl("txt_SplInstructionValue");
TextBox txtPONumber = (TextBox)page.FindControl("txt_PONumberValue");
 if (dischargeDetails.Count > 0)
 {
txtShipTo.Text = dischargeDetails[0].Site_ID.ToString();
txtSiteName.Text = dischargeDetails[0].SiteName;
txtAddress.Text = dischargeDetails[0].SiteAddress + dischargeDetails[0].SiteName2;
txtSplInstructions.Text = dischargeDetails[0].DeliveryWindow;
txtPONumber.Text = dischargeDetails[0].PONumber.ToString();
 }
 else
 {
txtShipTo.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
txtSiteName.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
txtAddress.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
txtSplInstructions.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
txtPONumber.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
 } break;
 }
 case "Compartments":
 {
RadPageView page = (RadPageView)e.Tab.PageView;
RadGrid grdDisharge = (RadGrid)page.FindControl("CompartmentLevelDischargeRadGrid"); //List<DischargeDetailExtraEntity> dischargeTabListinstance = new List<DischargeDetailExtraEntity>();
 //dischargeTabListinstance = dischargeDetailManager.GetDischargeDetailWSListByDischargeId(discharge);
 //Session["_storeCompartmentDischargeTable"] = dischargeTabListinstance;
 List<DischargeDetailExtraEntity> dischargeTabListinstance = (List<DischargeDetailExtraEntity>)Session["_storeCompartmentDischargeTable"];
grdDisharge.DataSource = dischargeTabListinstance;
grdDisharge.DataBind();
 break;
 }
 case "Products":
 {
RadPageView page = (RadPageView)e.Tab.PageView;
RadGrid grdDishargeProducts = (RadGrid)page.FindControl("ProductLevelDischargeRadGrid");
 //List<DischargeDetailExtraEntity> ProductTabinstance = new List<DischargeDetailExtraEntity>();
 //ProductTabinstance = dischargeDetailManager.GetDischargeDetailByDischargeIdAtProductlevel(discharge);
 //Session["_storeProductDischargeTable"] = ProductTabinstance;
 List<DischargeDetailExtraEntity> ProductTabinstance = (List<DischargeDetailExtraEntity>)Session["_storeProductDischargeTable"];
grdDishargeProducts.DataSource = ProductTabinstance;
grdDishargeProducts.DataBind();
 break;
 }
 }
 }
protected void btn_editPONumber_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        DischargeDal dischargedal=new DischargeDal();
        RadTabStrip rad = (RadTabStrip)DischargeRadGrid.Page.FindControl("DischargeTabStrip");
        ImageButton btneditPONumber = (ImageButton)DischargeRadGrid.Page.FindControl("btn_editPONumber");
        TextBox txtPONumber = (TextBox)DischargeRadGrid.Page.FindControl("txt_PONumberValue");
       //DischargeTabStrip.
       List<DischargeEntity> currentList = (List<DischargeEntity>)Session[_sesDischargeList];
       //DischargeEntity de = currentList[(Int32)Session[_vsCurrentDischargeIndex]];
       DischargeEntity de = currentList[0];
       Int64 discharge = 0;
       discharge = Convert.ToInt64(Session[_lastDischargeSelect1].ToString());
       if (!editableMode)
        {
            return;
        }
       if (btneditPONumber.ImageUrl.EndsWith("PenEditIcon.gif"))
        {
            if (!(Boolean)de.Planned)
            {
                txtPONumber.Enabled = true;
            }
            else
            {
                txtPONumber.Enabled = false;
            }
           
            btneditPONumber.ImageUrl = "~/images/UpdateTick.gif";
            //ChkBox_UpdateShipment.Checked = false;
        }
        else if (btneditPONumber.ImageUrl.EndsWith("UpdateTick.gif"))
        {
            var dischargeEntity = new DischargeEntity
            {
                Discharge_ID = discharge,
                PONumber=Convert.ToInt64(txtPONumber),            };
            dischargeEntity.Discharge_ID = dischargedal.UpdatePONumberByDischargeId(dischargeEntity).Discharge_ID;
        }
        btneditPONumber.ImageUrl = "~/images/PenEditIcon.gif";
        txtPONumber.Enabled = false;
    }
Please check the above code i have written in the btn_editPONumber_Click method.in that method i am unable to the control for the imagebutton and textbox.
How to find the control for the image button and textbox in this method.

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 07 Nov 2014, 09:27 AM
Hello Sudhakar,

In order to get reference to the TextBox control you could use the following approach. In the Click handler for the ImageButton reference the container of the control. Then you can use the FindControl() method to reference the TextBox.

protected void btn_editPONumber_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
    ImageButton button = sender as ImageButton;
    TextBox textBox = button.NamingContainer.FindControl("txt_PONumberValue") as TextBox;
 
    // add additional logic here
}


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.

 

0
Sudhakar
Top achievements
Rank 1
answered on 07 Nov 2014, 11:45 AM
Hi Viktor,

Thanks for the solution. It is working fine for me.

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