Text field not recognized in gridview

I am trying to use a calendar control to populate a text box in a gridview cell in edit mode.

Error with this line.

<a href="javascript:OpenPopupPage('Calendar.aspx','<%= txtGvEditTeDate.ClientID %>','<%= Page.IsPostBack %>');">

It does not recognize the text field.

Compilation error

Compiler Error Message: CS0103: The name 'txtGvEditTeDate' does not exist in the current context

Source Error:

<EditItemTemplate>
        <asp:TextBox ID="txtGvEditTeDate" runat="server"   onfocus="blur();"
             Text='<%# Bind("TimeEntryDate", "{0:d}") %>'>
        </asp:TextBox>

       <a href="javascript:OpenPopupPage('Calendar.aspx','<%= txtGvEditTeDate.ClientID %>','<%= Page.IsPostBack %>');">
       <img src="images/icon-calendar.gif" border="0" align="middle" ></a>
</EditItemTemplate>

Edit

I added runat = "server" in <a>, and now I do not receive an error message, but when a date is selected in the calendar control, it will not be inserted into the txtGvEditTeDate text box.

+3
source share
2 answers

Think do it <a id="r1" runat="server" />

RowDataBound RowEditing :

var ctl = e.Row.FindControl("txtGvEditTeDate");
var link = e.Row.FindControl("r1");
link.href = "javascript ...";

. , : e.Row.Cells [] , .

EDIT: , , , gridview ( , , ), , txtGvEditTeDate, . javascript, ​​ href . .

+2

textBox EditItemTemplate, . findcontrol, , javascript, .

0

Source: https://habr.com/ru/post/1759365/


All Articles