Reputation:
i am creating a web app in which i have a file upload button on gridview,my file upload button is disable by default, on my rowediting, i want to enable my file upload button
this is my aspx page
<asp:TemplateField HeaderText="Attachtment">
<ItemTemplate>
<%--<asp:LinkButton ID="lnkDownload" Text="Download" CommandArgument='<%# Eval("FileData") %>' runat="server" OnClick="lnkDownload_Click"></asp:LinkButton>--%>
<asp:FileUpload ID="fpTask" cssstyle="width:100%; margin-left:-10px;" Enabled="false" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="([a-zA-Z0-9\s_\\.$&*#@()+\-:])+(.doc|.docx|.pdf|.jpg|.png|.jpeg|.xls|.xlsx|.txt|.gif)$"
ControlToValidate="fpTask" runat="server" ForeColor="Red" ErrorMessage="selected file is not valid"
Display="Dynamic" />
</ItemTemplate>
</asp:TemplateField>
and this is my css page
protected void dgvEdit_RowEditing(object sender, GridViewEditEventArgs e)
{
dgvEdit.EditIndex = e.NewEditIndex;
LoadGridTask("EDIT", Session["CurrentUser"].ToString(), Session["TaskID"].ToString());
}
what i need to do to change fileupload button to enabled=true
?
Upvotes: 1
Views: 712
Reputation: 4036
Use FindControl
to find the instance of FileUpload
object and update its Enabled
property:
protected void dgvEdit_RowEditing(object sender, GridViewEditEventArgs e)
{
dgvEdit.EditIndex = e.NewEditIndex;
FileUpload fpTask =(FileUpload) dgvEdit.Rows[e.RowIndex].FindControl("fpTask");
fpTask.Enabled = true;
LoadGridTask("EDIT", Session["CurrentUser"].ToString(), Session["TaskID"].ToString());
}
Upvotes: 0