Saturday, July 28, 2007

Find Data Present in DataGrid in CodeBehind

Declare a Global Variable int as show below

int iFlag = 0;

protected void imgbtnUpdateEmployee_Click(object sender, ImageClickEventArgs e)
{
int iInc = 0;
foreach (DataGridItem df in dgEmployee.Items)
{
Label lblPageName = df.FindControl("lbl") as Label;
TextBox dgtxtFind = df.FindControl("dgtxt") as TextBox;
if (dgtxtFind.Text.Trim() != "")
{
oCreate.EmpId = iEmpId;
oCreate.DeptId = Convert.ToInt32(dgEmployee.Items[iInc].Cells[0].Text);
oCreate.DeptName = Convert.ToInt32(lblPageName.Text);
oCreate.EmpName = dgtxtFind.Text.Trim().ToString();
iFlag = oCreate.UpdateEditEmpBLL();
iInc++;
if (iFlag == 1)
{
iCount++;
}
}
}

0 comments: