From a drop of water
Http://www.cnblogs.com/yidishui
Obtain the ID of the inserted record Void Page_load ( Object Sender, system. eventargs E)
{
// Database connection string
String Connstr = System. configuration. configurationsettings. deleettings [ " Connectionsqlserver " ];
// Create an insert SQL statement and call the @ identity function to return the id value
String Insert_query = " Insert into categories (categoryname, description) values ('it', 'internet '); "
+ " Select @ identity as 'identified '; " ;
// Perform database operations
Sqlcommand mycommand = New Sqlcommand (insert_query, New Sqlconnection (connstr ));
Mycommand. Connection. open ();
Mylabel. Text = Mycommand. executescalar (). tostring ();
Mycommand. Connection. Close ();
}
Move the cursor to the row of the DataGrid to change the color. Private Void Datagrid1_itemdatabound ( Object Sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
If (E. Item. itemtype = Listitemtype. Item | E. Item. itemtype = Listitemtype. alternatingitem)
{
// Add Custom Attributes. When the mouse moves over, set the background color of the row to "6699ff" and save the original background color.
E. Item. Attributes. Add ( " Onmouseover " , " Stylecolor = This. style. backgroundcolor; this. style. backgroundcolor = '# 6699ff' " );
// Add custom properties to restore the background color of the row when the mouse moves
E. Item. Attributes. Add ( " Onmouseout " , " This. style. backgroundcolor = stylecolor " );
}
}
Blog site
Http://xiexiaokui.cnblogs.com