I am trying to get Data from database to text box on select index changed i am getting output, But i use simple if statement inside my loop but its not working where am i doing wrong Please help me ??
let me explain I use two text box txtEmployeeNumber and txtEmployeename on txtEmployeeNumber_TextChanged i have written my logic code
protected void txtEmployeeNumber_TextChanged(object sender, EventArgs e)
{
string EmployeeNo = "";
string EmployeeName = "";
int Row = 0;
foreach (GridViewRow row in grdRegister.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
EmployeeNo = (row.Cells[1].FindControl("txtEmployeeNumber") as TextBox).Text;
}
DataTable dt = new DataTable();
dt = (DataTable)Application["Employee_details"];
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["Employee_ID"].ToString() == EmployeeNo)
{
(row.Cells[2].FindControl("txtEmployeeName") as TextBox).Text = dt.Rows[i]["Employee_Name"].ToString();
EmployeeName = (row.Cells[2].FindControl("txtEmployeeName") as TextBox).Text;
break;
}
else if ((row.Cells[2].FindControl("txtEmployeeName") as TextBox).Text == "")
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "alert('No Data Found...')", true);
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire