In my application i need to read the spreadsheet data and display the error message for each and every empty cell that the cell is empty please provide the corresponding text

NAME    ADDRESS   DOB       PHONE    EMAIL ID             LOGIN NAME         PASSWORD
bhaya            01/22/90               
                 01/03/80          sandya@gmail.com     sandhya       sandhya
navya                              navya@gmail.com      
geeta            07/04/96                                              geetha

for example let us assume that the data is in this way in the spread sheet now i need to dynamically check each and every row and column that is empty and display the message to the user that all those fields which are empty and insert the data only if all the fields are provide in the sheet if any one field is empty the data should not be inserted into database how can i do this.while reading the spread sheet data i should show these message that means in button1_click event

 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";
            }
            GridView1.Visible = true;

        }
        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;

        }




<asp:FileUpload ID="FileUpload1" runat="server"/>
          <asp:Button ID="Button1" runat="server" Text="ReadFile" OnClick="Button1_Click" />

Related posts

Recent Viewed