private void DataGrid1_ItemDataBound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {SqlConnection conn = new SqlConnection (System.Configuration.ConfigurationSettings.AppSettings [ "conn"]); SqlDataAdapter da = new SqlDataAdapter ( "select * from dep ", conn); DataSet DS = New Dataset (); DA.FILL (DS," Table1 "); if (E.Item.itemType == ListItemType.editItem) {DropDownList DDL = (DropDownList) E.Item.FindControl "dep"); ddl.datasource = ds.tables ["Table1"]; ddl.datatextfield = "depname"; DDL.DataValuefield = "depid"; ddl.database (); ddl.items.FindByValue (Convert.Tostring DataBinder.eval ("Depid")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))). SELECTED = true; TextBox txt1 = (TextBox) E.Item.cells [0] .controls [0]; txt1.attributes.add ("style" , "Border-color: red; border-width: 1px; border-style: solId;"); // Setting the style of text box // Note: cells [i] .controls [i] represents i 1 column I 1 control, you need to change into your own column}}