2008-02-01

Run No. (Seq No.) on grid

//Loop data on grid
for (int i = 0; i < dgdshow.Items.Count; i++)
{
dgdshow.Items[i].Cells[1].Text = ((dgdshow.CurrentPageIndex*dgdshow.PageSize)+(i+1)).ToString();
}
----------
//string
private int MaxSeq(string new_seq)
{
int max = 0;
string seq = "";
for (int i = 0; i < dgdshow.Items.Count; i++)
{
seq = dgdshow.Items[i].Cells[6].Text;
if(int.Parse(seq.ToString())>max)
{
max = int.Parse(seq.ToString());
}
}
max = max+1;
return max;
}
----------
//Data Table
private int MaxSeq_No(DataTable dt)
{
int max = 0;
if(dt != null)
{
if(dt.Rows.Count>0)
{
foreach(DataRow dr in dt.Rows)
{
if(int.Parse(dr["seq"].ToString())>max)
{
max = int.Parse(dr["seq"].ToString());
}
}
}
}
return max;
}
Google