protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView drv = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
DropDownList dp = (DropDownList)e.Row.FindControl("DropDownList1");
DataTable dt = load_department();
for (int i = 0; i < dt.Rows.Count; i++)
{
ListItem lt = new ListItem();
lt.Text = dt.Rows[i][0].ToString();
dp.Items.Add(lt);
}
dp.SelectedValue = drv[3].ToString();
RadioButtonList rbtnl = (RadioButtonList)e.Row.FindControl("RadioButtonList1");
rbtnl.SelectedValue = drv[5].ToString();
CheckBoxList chkb = (CheckBoxList)e.Row.FindControl("CheckBoxList2");
string[] strSplitArr = ((DataRowView)e.Row.DataItem)["skill"].ToString().Split(',');
foreach (ListItem oItem in chkb.Items)
{
for (int i = 0; i < strSplitArr.Length; i++)
{
if (oItem.Value == strSplitArr[i].Trim())
{
oItem.Selected = true;
break;
}
}
}
ListBox llb = (ListBox)e.Row.FindControl("ListBox1");
string[] strSplit = ((DataRowView)e.Row.DataItem)["project"].ToString().Split(',');
foreach (ListItem oItem in llb.Items)
{
for (int i = 0; i < strSplit.Length; i++)
{
if (oItem.Value == strSplit[i].Trim())
{
oItem.Selected = true;
break;
}
}
}
}
string empno = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "empno"));
LinkButton lnkbtnresult = (LinkButton)e.Row.FindControl("btndelete");
lnkbtnresult.Attributes.Add("onclick", "javascript:return ConfirmationBox('" + empno + "')");
}
}
No comments:
Post a Comment