private void dg_Class_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string SqlSelect = "select dep_id,dep_name,dep_code from db_dep";
if(e.Item.ItemType==ListItemType.EditItem)
{
DropDownList DDLinDG = (DropDownList)(e.Item.FindControl("ddl_depnameInDG"));
DDLinDG.DataSource = NN.ds(SqlSelect).Tables[0];
DDLinDG.DataValueField = "dep_id";
DDLinDG.DataTextField = "dep_name";
DDLinDG.DataBind();
DDLinDG.Items.FindByText(Convert.ToString(DataBinder.Eval(e.Item.DataItem,"dep_name"))).Selected=true;
}
}
{
string SqlSelect = "select dep_id,dep_name,dep_code from db_dep";
if(e.Item.ItemType==ListItemType.EditItem)
{
DropDownList DDLinDG = (DropDownList)(e.Item.FindControl("ddl_depnameInDG"));
DDLinDG.DataSource = NN.ds(SqlSelect).Tables[0];
DDLinDG.DataValueField = "dep_id";
DDLinDG.DataTextField = "dep_name";
DDLinDG.DataBind();
DDLinDG.Items.FindByText(Convert.ToString(DataBinder.Eval(e.Item.DataItem,"dep_name"))).Selected=true;
}
}