Allow fileuploader to accept multiple files while adding new record and allow single in edit mode in GridView using C# in ASP.Net

Last Reply on Sep 11, 2017 01:22 AM By AnandM

Posted on Sep 11, 2017 01:16 AM

My file uploader allows multiple selection when i insert data in data base and that inserted data is displayed in gridview how can i make that file uploader multiple selection false when editing the records in gridview aspx file upload code-

    <asp:FileUpload ID="fil1" runat="server" multiple="multiple" />

    .cs code

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
          ImageButton img = sender as ImageButton;
         GridViewRow grv = img.Parent as GridViewRow;
        string[] textboxValues = Request.Form.GetValues("DynamicTextBox"); //Request.Form["txtSpeciality"];
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        this.Values = serializer.Serialize(textboxValues);
        if (e.CommandName == "mybutton")
            GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
            int rowIndex = gvr.RowIndex;
            Label Itemid = (Label)GridView1.Rows[rowIndex].FindControl("lblID");
            ID1 = (Itemid).Text;
            Session["ID"] = ID1;
            string Role = string.Empty;
            FileUpload fil1 = grv.FindControl("fil1") as FileUpload;
            fil1.AllowMultiple = false;

This question does not have replies that have been liked.