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

don't have access to the id in code behind

3 Answers 601 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Diogo
Top achievements
Rank 1
Diogo asked on 16 Oct 2015, 09:49 AM

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>​

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 21 Oct 2015, 06:49 AM
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
0
Diogo
Top achievements
Rank 1
answered on 21 Oct 2015, 02:11 PM

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.

0
Viktor Tachev
Telerik team
answered on 26 Oct 2015, 09:01 AM
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
Tags
Ajax
Asked by
Diogo
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Diogo
Top achievements
Rank 1
Share this question
or