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
查看全文
相关阅读:
define和typedef
keil5配置stm32库函数开发
SPI、CAN、I2C
flash,sram
关于网络地址
关于定时器、波特率、TH和TL值的计算
关于串口工作方式
ad各层
AD快捷键
OAuth2.0 微博登陆网站功能的实现(一)获取用户授权及令牌 Access Token
原文地址:https://www.cnblogs.com/xiexiaokui/p/573382.html
最新文章
详解ASP.NET提取多层嵌套json数据的方法
R语言学习——因子
R语言学习——列表
R语言学习——列表
R语言学习——数组
R语言学习——数组
R语言学习——向量,矩阵
R语言学习——向量,矩阵
R语言学习——欧拉计划(11)Largest product in a grid
iOS:编译错误[__NSDictionaryM objectAtIndexedSubscript:]: unrecognized selector sent to instance 0xa79e61
热门文章
HDU 1113 Word Amalgamation (map 容器 + string容器)
2015年年终总结
[Erlang危机](4.2)Remsh
漫谈并发编程(五):线程之间的协作
#定位系统性能瓶颈# perf
1090. Highest Price in Supply Chain (25) -计层的BFS改进
拥抱Mac之码农篇
防火墙设置对外开放port
MVC发送邮件
C语言结构体,点运算和箭头运算
Copyright © 2011-2022 走看看