I have an on click event and I would like to bind to the Grid on click and make it view able. My code is not working. The grid is not made view able on button click.
My code:
. protected void btnFind_Click(object sender, EventArgs e)
{
strFind = txtFind.Text;
AddFileNames(dataDir);
foreach (var fileName in allFiles)
{
Document doc = new Document(fileName);
Regex regex = new Regex(strFind, RegexOptions.IgnoreCase);
FindReplaceOptions options = new FindReplaceOptions();
doc.Range.Replace(regex, new ProcessFiles(), false);
if (doc.HasRevisions == true)
{
//string strFileName = System.IO.Path.GetFileName(fileName);
changedFiles.Add(fileName);
Session.Add("ChangeFilesList", changedFiles);
doc.Save(fileName);
}
}
txtFind.Text = string.Empty;
RadGrid1.DataSource = GetDocuments();
}
private DataTable GetDocuments()
{
var dt = new DataTable();
List<string> fileEntries = Session["allFilesList"] as List<string>;
string[] files = fileEntries.ToArray();
dt.Columns.Add("ID", typeof(Int32));
dt.Columns.Add("DirectoryName", typeof(string));
dt.Columns.Add("FileName", typeof(string));
dt.Columns.Add("LastModifiedTime", typeof(DateTime));
dt.Columns.Add("FilePath", typeof(string));
dt.Columns.Add("BinaryData", typeof(byte[]));
dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
for (int i = 0; i < files.Length; i++)
{
var dr = dt.NewRow();
dr["ID"] = i;
var fileInfo = new FileInfo(fileEntries[i]);
dr["DirectoryName"] = fileInfo.Directory.Name;
dr["FileName"] = fileInfo.Name;
dr["LastModifiedTime"] = fileInfo.LastWriteTime;
dr["FilePath"] = fileEntries[i];
dr["BinaryData"] = File.ReadAllBytes(fileEntries[i]);
dt.Rows.Add(dr);
}
return dt;
}