Click here to Skip to main content
13,349,539 members (49,767 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have multiple file upload control in grid view,i want to clear/reset file upload control when wrong file selection.

fileupload1 btnReset1
fileupload2 btnReset2

when i click btnReset2 then only clear value for fileupload2

How can i do this using java script.
Please help me

Thank you all in advance
Posted 8-Jul-12 23:01pm
Sanjay Kunjam 9-Jul-12 4:24am
you can filter your file selection in upload event. You don't need to clear when selected file is wrong its automatically clears fileupload1 control. Why you want to out an extra button for clear?
jignesh,surat 9-Jul-12 9:29am
Hi... Sanjay Kunjam
Thanks for reply.
but i need to cancel the selected file that’s why I have put reset button on that buttons click event I’m clearing that rows file upload control textbox. Currently in my code control is not clearing but I want to clear specific file upload control my code is as follows (I’m doing this by using JS).

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

JS Code:-
<script type="text/javascript">
        function hi(ob) {
            var grid = document.getElementById("<%= GridView1.ClientID %>");
            var inputs = grid.getElementsByTagName("input");
            var fileUpload;
            var strRowNo ="_")[3];//get row number
            for (var i = 0; i < inputs.length; i++) {

                if (inputs[i].type == "file") {

                    fileUpload = inputs[i];

                    if (i == strRowNo) {

                        fileUpload.value = "";






Aspx Code:-
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                    <asp:BoundField DataField="A" HeaderText="A" />
                    <asp:BoundField DataField="B" HeaderText="B" />
                    <asp:BoundField DataField="C" HeaderText="C" />
                    <asp:TemplateField HeaderText="File">
                            <div id="fuDiv" runat="server">
                                <asp:FileUpload ID="fupFile" runat="server" />
                    <asp:TemplateField HeaderText="Reset">
                            <asp:Image ID="ibtnReset" runat="server" onClick="javascript:hi(this);" />

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180111.1 | Last Updated 10 Jul 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100