don't have access to the id in code behind

4 posts, 0 answers
  1. Diogo
    Diogo avatar
    2 posts
    Member since:
    Oct 2015

    Posted 16 Oct 2015 Link to this post

    Hello, 

     

    I have one telerik radgrid with EditFormSttings and i have two fields (ID="editCodEmp" e ID="editNIFFilho") where (Enabled="false"). In code behind i need make (enable="true"), how?

     

    My Code Behind:

     protected void Insert_Click(object source, EventArgs e)//Telerik.Web.UI.GridItemEventArgs
    {
    try
    {
    error.Style["Display"] = "none";
    success.Style["Display"] = "none";

    how to access "editCodEmp"?

    how to access "editNIFFilho"?

    CTGrid.MasterTableView.IsItemInserted = true;
    CTGrid.MasterTableView.Rebind();
    }
    }
    catch (Exception ex)
    {
    Logger.FillLog(ex, Session["Username"].ToString(), Session["Produto"].ToString(), "Insert_Click");
    error.Style["Display"] = "block";
    errorMessage.Text = ConfigurationManager.AppSettings["genericError"].ToString();
    }
    }

     

    My Code ASPX:

     <telerik:RadGrid ID="CTGrid" AllowSorting="true" AutoGenerateColumns="false" PageSize="10"
    AllowPaging="true" AllowMultiRowSelection="true" runat="server" GridLines="None"
    Width="100%" Skin="TicketBlue" EnableEmbeddedSkins="false" OnItemDataBound="CTGrid_ItemDataBound"
    OnUpdateCommand="CTGrid_UpdateCommand" OnInsertCommand="CTGrid_InsertCommand"
    OnDeleteCommand="CTGrid_DeleteCommand" OnItemCreated="CTGrid_ItemCreated">
    <MasterTableView Width="100%" Summary="RadGrid table" EditMode="EditForms" HierarchyLoadMode="Client"
    ExpandCollapseColumn-Display="false" InsertItemDisplay="Top" DataKeyNames="id,NIFFilho, DescricaoEstado, DataRegisto">
    <DetailTables>

    ..........

     

     

    <EditFormSettings EditFormType="Template">
    <FormTemplate>
    <table align="left" width="100%" class="editTemplate">
    <tr>
    <td>
    Nº Contribuinte *
    </td>
    <td>
    <asp:TextBox ID="editCodEmp" Width="70px" CssClass="editFields" MaxLength="9" Enabled="false" runat="server" Text='<%# Bind("CodEmp") %>'></asp:TextBox>
    </td>
    <td>
    Nome do Funcionário *
    </td>
    <td>
    <asp:TextBox ID="editNomeFuncionario" Width="250px" CssClass="editFields" MaxLength="40" runat="server"
    Text='<%# Bind("NomeFuncionario") %>'></asp:TextBox>
    </td>
    <td>
    Nome a gravar no Cartão *
    </td>
    <td>
    <asp:TextBox ID="editNomeGravar" Width="160px" CssClass="editFields" MaxLength="21" runat="server" Text='<%# Bind("NomeGravar") %>'></asp:TextBox>
    </td>
    </tr>
    <asp:PlaceHolder ID="PlaceHolder1" runat="server" OnLoad="MakeVisibleOrNot">
    <tr id = "CartaoFilhos" runat = "server">
    <td>
    Nº Contr. Filho *
    </td>
    <td>
    <asp:TextBox ID="editNIFFilho" Width="70px" Enabled="False" CssClass="editFields" MaxLength="9" runat="server"
    Text='<%# Bind("NIFFilho") %>'></asp:TextBox>
    </td>

    ...........

    <tr>
    <td colspan="8">
    <br />
    * Campos obrigatórios
    </td>
    </tr>
    <tr>
    <td align="left" colspan="6">
    <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Gravar" : "Gravar" %>'
    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
    </asp:Button>&nbsp;
    <asp:Button ID="btnCancel" Text="Cancelar" runat="server" CausesValidation="False"
    CommandName="Cancel"></asp:Button>
    </td>
    </tr>
    <asp:HiddenField ID="id" runat="server" Value='<%# Bind( "id") %>' />
    </table>
    </FormTemplate>
    </EditFormSettings>
    </MasterTableView>​

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 21 Oct 2015 Link to this post

    Hello Diogo,

    In order to access the TextBox controls in the EditForm Template you should use the approach illustrated in the following article. Check out the part referring to template.



    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Diogo
    Diogo avatar
    2 posts
    Member since:
    Oct 2015

    Posted 21 Oct 2015 in reply to Viktor Tachev Link to this post

    Hi Viktor,

     

    Thanks, but I have not found there the solution helped. However I found the best way of solving the problem in your link.

  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 26 Oct 2015 Link to this post

    Hello Diogo,

    I am glad that the issue is resolved. Thank you for sharing where you have found the solution with the community.

    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top