Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all...

am using file upload control like
<asp:GridView ID="GridView1" CellPadding="4" runat="server" OnRowCommand="GridView1_RowCommand" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PageSize="5" Width="95%" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDeleting="GridView1_RowDeleting">
<alternatingrowstyle backcolor="aliceBlue">
<HeaderStyle HorizontalAlign="Left" />
<columns> <asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="eid" runat="server" Text='<%# Eval("uid") %>'>


<asp:BoundField DataField="ccode" HeaderText="Company Code" />
<asp:BoundField DataField="cname" HeaderText="Company Name" />
<asp:TemplateField HeaderText="Company Logo">
<itemtemplate>
<asp:Image ID="LogoImage" ImageUrl="~/images/logo-not-available.jpg" runat="server"
Height="80px" Width="150px" />


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="logopathlbl" runat="server" Text='<%# Eval("logopath") %>'>


<asp:TemplateField HeaderText="Logo Upload">
<itemtemplate>
<asp:FileUpload ID="FileUpload4" runat="server" />
<asp:Button ID="bt_upload" runat="server" EnableViewState="False" Text="Upload" CommandName="Upload" />


on code behind
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Button bts = e.CommandSource as Button;
Response.Write(bts.Parent.Parent.GetType().ToString());
if (e.CommandName.ToLower() == "upload")
{
FileUpload fu = bts.Parent.Parent.FindControl("FileUpload4") as FileUpload;
if (fu.HasFile)
{

}
}

}
fu object finding fileupload control but not taking the file name i con't save file
am not getting file can any one help me please
thanks in advance
Posted
Updated 17-Jul-11 20:10pm
v2

1 solution

hello,

try with fu.PostedFile.FileName.

hoping you'll get it.

thanks
sanjeev
 
Share this answer
 
Comments
tulasiram3975 18-Jul-11 2:41am    
dr SanjeevSingh,
first it won't going into if(fu.HasFile) loop it means it wont have file it seems how could i?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900