Hi,
when i am binding datatable to datagridview, it is not showing all the records in the datagridview..
it is displaying only 1 Record in datagridview..
actual records in datatable are 12.
have any idea,let me know..
here is my code
public static DataTable dtable = new DataTable();
private void ScheduledJobs_Load(object sender, EventArgs e)
{
try
{
FillGrid();
if (dtable.Rows.Count > 0)
{
dgrid.DataSource = dtable;
}
}
catch { }
}
private void FillGrid()
{
try
{
if (dtable.Rows.Count == 0)
{
ProcessStartInfo ps = new ProcessStartInfo("SCHTASKS", "/QUERY /fo table");
ps.RedirectStandardOutput = true;
ps.UseShellExecute = false;
Process p = Process.Start(ps);
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.BeginOutputReadLine();
}
}
catch { }
}
System.Collections.ArrayList ar = new System.Collections.ArrayList();
int first = 0;
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
try
{
if (first == 0 && dtable.Columns.Count == 0)
{
dtable.Columns.Add("Task Name");
dtable.Columns.Add("Next RunTime");
dtable.Columns.Add("Status");
}
ar.Add(e.Data);
if (first > 2 && ar[first] != null)
{
DataRow dr = dtable.NewRow();
dr[0] = ar[first].ToString().Substring(0, ar[first].ToString().IndexOf(':') - 2).Trim();
dr[1] = ar[first].ToString().Substring(ar[first].ToString().IndexOf(':') - 2, 20).Trim();
dr[2] = ar[first].ToString().Substring(ar[first].ToString().IndexOf(':') + 18).Trim();
dtable.Rows.Add(dr);
}
first++;
}
catch { }
}
Thanks in advance.
Pawan.