Clear/Reset file upload control in grid view
<p>I have multiple file upload control in asp.net grid view,i want to clear/reset file upload control when wrong file selection.</p>

<p>fileupload1 btnReset1
fileupload2 btnReset2
...</p>

<p>when i click btnReset2 then only clear value for fileupload2</p>

<p>How can i do this using java script. </p>

<p>Thank you all in advance</p>

<p>My code is as below.</p>

<p>JS Code:-</p>

<pre><code>&lt;script type="text/javascript"&gt;
        function hi(ob) {
            debugger;
            var grid = document.getElementById("&lt;%= GridView1.ClientID %&gt;");
            var inputs = grid.getElementsByTagName("input");
            var fileUpload;
            var strRowNo = ob.id.toString().split("_")[3];//get row number
            alert(strRowNo);
            for (var i = 0; i &lt; inputs.length; i++) {
                if (inputs[i].type == "file") {
                    fileUpload = inputs[i];
                    if (i == strRowNo) {
                        fileUpload.value = "";
                    }
                }
            }
        }
    &lt;/script&gt;

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