the code used for list box control , i like to use for gridview
<p>I have seen 1 article with below address</p>

<p><a href="http://www.c-sharpcorner.com/UploadFile/rohatash/uploading-multiple-files-with-listbox-in-Asp-Net/" rel="nofollow">http://www.c-sharpcorner.com/UploadFile/rohatash/uploading-multiple-files-with-listbox-in-Asp-Net/</a></p>

<p>That use list box for showing uploaded files</p>

<pre><code>if (ListBox1.Items.Contains(new ListItem(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName))))
{
      Label1.Text = "File already in the ListBox";
}
else
{
      Files.Add(FileUpload1);
      ListBox1.Items.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName));
      Label1.Text = "Add another file or click Upload to save them all";
}
</code></pre>

<p>,now I like to do that in grid view, but I have problem to transfer below code for grid view, it has problem it does not prevent duplicate uploaded file.</p>

<pre><code>for (int i = 0; i &lt; count; i++)
{
     if (GridViewEfile.Rows[i].Cells[1].Text == FileName)
     {
             Label2.Text = "File already in the list";
             break;
     }
}
</code></pre>

<p>What I have done for gridview:</p>

<pre><code>for (int i = 0; i &lt; count; i++)
{
      if (GridViewEfile.Rows[i].Cells[1].Text == FileName)
      {
            Label2.Text = "File already in the list";
            break;
      }
}

for (int j = 0; j &lt; count; j++)
{
      dr = dt.NewRow();
      dr["File Name"] = GridViewEfile.Rows[j].Cells[1].Text;
      dr["File Size"] = GridViewEfile.Rows[j].Cells[2].Text;
      dt.Rows.Add(dr);
}

dr = dt.NewRow();
dr["File Name"] = FileName;

if (size &gt; 0)
     dr["File Size"] = size.ToString() + " KB";
else
     Label2.Text = "File size cannot be 0";

dt.Rows.Add(dr);

GridViewEfile.DataSource = dt;
GridViewEfile.DataBind();
</code></pre>
