zoukankan
html css js c++ java
获得插入记录标识号, 鼠标移到DataGrid的行更改颜色(转)
转自一滴水
http://www.cnblogs.com/yidishui
获得插入记录标识号
void
Page_Load(
object
sender, System.EventArgs e)
{
//
数据库连接字符串
string
ConnStr
=
System.Configuration.ConfigurationSettings.AppSettings[
"
ConnectionSqlServer
"
];
//
创建插入SQL语句及调用@@identity函数返回标识值
string
insert_query
=
"
insert into Categories (CategoryName,Description) values ('IT', 'Internet');
"
+
"
SELECT @@identity AS 'identity';
"
;
//
执行数据库操作
SqlCommand myCommand
=
new
SqlCommand(insert_query,
new
SqlConnection(ConnStr));
myCommand.Connection.Open();
myLabel.Text
=
myCommand.ExecuteScalar().ToString();
myCommand.Connection.Close();
}
鼠标移到DataGrid的行更改颜色
private
void
DataGrid1_ItemDataBound(
object
sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if
(e.Item.ItemType
==
ListItemType.Item
||
e.Item.ItemType
==
ListItemType.AlternatingItem)
{
//
添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
e.Item.Attributes.Add(
"
onmouseover
"
,
"
StyleColor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'
"
);
//
添加自定义属性,当鼠标移走时还原该行的背景色
e.Item.Attributes.Add(
"
onmouseout
"
,
"
this.style.backgroundColor=StyleColor
"
);
}
}
blog site
http://xiexiaokui.cnblogs.com
查看全文
相关阅读:
idea自定义servlet模板
jsp基础-指令,内置对象,动作,EL表达式,JSTL技术
cookie和session
HttpServletRequest
IO字符流
IO字节流
递归
File 类
JDBC数据库连接
Map接口
原文地址:https://www.cnblogs.com/xiexiaokui/p/573382.html
最新文章
http协议
http协议和类的加载器
XML
打印流
java-面对对象构造方法
java面对对象-抽象类与接口
2019年9月23日 java面对对象-继承
java面对对象-封装
java面对对象-类与对象
java创建集合的常用格式
热门文章
java数组
java中的流程控制语句总结
mysql基础语句(一)
js数组的操作
oracle基础(2)
常见异常
oracle基础(1)
jquery获取节点
JDBC中MySQL的事务
DBUtils和DBCP连接池
Copyright © 2011-2022 走看看