M
Morris Neuman
Hi,
I have a gridview (GridView1) which has several bound fields. One of the
fields (DirectoryListing) is a template field. In the Edit template field, I
have a textbox (TextBox1), a fileupload control (FileBrowse1) and a button
control (SelectButton).
Definition of GridView1 Template Field
<asp:TemplateField HeaderText="DirectoryListing"
SortExpression="DirectoryListing">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("DirectoryListing") %>'
Width="128px"></asp:TextBox>
<br />
<asp:FileUpload ID="FileSelect" runat="server" />
<asp:Button ID="SelectButton" runat="server"
onclick="SelectButton_Click"
Text="Select File" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Eval("DirectoryListing") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
In edit mode, the user can click on FileBrowse1 and select a file, then they
can click on the SelectButton to move FileBrowse1.PostedFile.FileName to the
TextBox1.
I created a SelectButten_Click event as follows:
protected void SelectButton_Click(object sender, EventArgs e)
{
TextBox1.Text = FileBrowse1.PostedFile.FileName.ToString();
}
I get error:
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'TextBox1' does not exist in the
current context
Source Error:
Line 89: protected void SelectButton_Click(object sender, EventArgs e)
Line 90: {
Line 91: TextBox1.Text = FileBrowse1.PostedFile.FileName.ToString();
Line 92: }
Line 93:
Source File:
c:\Inetpub\wwwroot\CMWebManager\SystemAdminOnly\Copies\Test-with Butto_Click
Examples.aspx Line: 91
If I have a TextBox, FileUpload and Butten controls outside of a template
control, the above works. I just don't know how to reference the controls
triggered by a click event from inside a template control.
Any help would be appreciated.
I have a gridview (GridView1) which has several bound fields. One of the
fields (DirectoryListing) is a template field. In the Edit template field, I
have a textbox (TextBox1), a fileupload control (FileBrowse1) and a button
control (SelectButton).
Definition of GridView1 Template Field
<asp:TemplateField HeaderText="DirectoryListing"
SortExpression="DirectoryListing">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("DirectoryListing") %>'
Width="128px"></asp:TextBox>
<br />
<asp:FileUpload ID="FileSelect" runat="server" />
<asp:Button ID="SelectButton" runat="server"
onclick="SelectButton_Click"
Text="Select File" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Eval("DirectoryListing") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
In edit mode, the user can click on FileBrowse1 and select a file, then they
can click on the SelectButton to move FileBrowse1.PostedFile.FileName to the
TextBox1.
I created a SelectButten_Click event as follows:
protected void SelectButton_Click(object sender, EventArgs e)
{
TextBox1.Text = FileBrowse1.PostedFile.FileName.ToString();
}
I get error:
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'TextBox1' does not exist in the
current context
Source Error:
Line 89: protected void SelectButton_Click(object sender, EventArgs e)
Line 90: {
Line 91: TextBox1.Text = FileBrowse1.PostedFile.FileName.ToString();
Line 92: }
Line 93:
Source File:
c:\Inetpub\wwwroot\CMWebManager\SystemAdminOnly\Copies\Test-with Butto_Click
Examples.aspx Line: 91
If I have a TextBox, FileUpload and Butten controls outside of a template
control, the above works. I just don't know how to reference the controls
triggered by a click event from inside a template control.
Any help would be appreciated.