You must Sign In to post a response.
  • Category: .NET

    Disabling grid after reloading the page

    Below is my code that is used to upload spread sheet using file uploader using this when i refreshes the page using reload this page in the browser i am able to upload the file multiple times but when i click on reload this page in the web page my grid should become disabled it is not getting disabled how can i do this

    protected void Page_Load(object sender, EventArgs e)
    {
    UploadStatusLabel.Text = "";
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    try
    {
    // Copy file to app folder
    string fileName = SaveToAppFolder(FileUpload1.PostedFile);

    // Read the File from App folder
    OdsReaderWriter obj = new OdsReaderWriter();
    DataSet dset = obj.ReadOdsFile(fileName);
    GridView1.DataSource = dset.Tables[0];
    GridView1.DataBind();
    }
    catch (Exception ex)
    {
    UploadStatusLabel.Text = "Only .ODS Files Are Allowed";
    }
    }
    string SaveToAppFolder(HttpPostedFile file)
    {
    // Specify the path to save the uploaded file to.
    string savePath = Server.MapPath(".") + "\\TempFiles\\";

    // Get the name of the file to upload.
    string fileName = FileUpload1.FileName;

    // Create the path and file name to check for duplicates.
    string pathToCheck = savePath + fileName;

    // Create a temporary file name to use for checking duplicates.
    string tempfileName = "";

    // Check to see if a file already exists with the
    // same name as the file to upload.
    if (System.IO.File.Exists(pathToCheck))
    {
    int counter = 2;
    while (System.IO.File.Exists(pathToCheck))
    {
    // if a file with this name already exists,
    // prefix the filename with a number.
    tempfileName = counter.ToString() + fileName;
    pathToCheck = savePath + tempfileName;
    counter++;
    }

    fileName = tempfileName;

    // Notify the user that the file name was changed.
    //UploadStatusLabel.Text = "A file with the same name already exists." +
    // "<br />Your file was saved as " + fileName;
    }
    else
    {
    // Notify the user that the file was saved successfully.
    //UploadStatusLabel.Text = "Your file was uploaded successfully.";
    }

    // Append the name of the file to upload to the path.
    savePath += fileName;

    // Call the SaveAs method to save the uploaded
    // file to the specified directory.
    FileUpload1.SaveAs(savePath);
    return savePath;

    }
  • #767060
    Hi,

    Where did you wrote code for disabling gridview?

    I didn't see any piece of code for the same, you just use below sample for disabling gridview


    GridView1.Visible=false;

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments