May 10, 2007

编辑的时候动态绑定DropDownList内容




This is a trick. Just write it here for external memory.


The condition is this:


In a datagrid, if there is a value, and the value is gained from database;


so when you modify, the value select become a dropdownlist, how can


And if the dropdownlist is gained from database, and when you modify, you have a exitex value, how can the dropdownlist select the existed value as default?




The code is as this:






' visible="false">












string TM=((Label)e.Item.FindControl("lblHideTM")).Text;


for(int i=0;i

ddlTrainingMethod.SelectedIndex=i;


if(ddlTrainingMethod.SelectedItem.Text==TM){


return;


}


}


No comments: