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
查看全文
相关阅读:
mysql改为mysqli几项注意
修改链接服务器地址提高下载速度
果然最适合码农的博客还是博客园
mysql
php 检测字符集
Internet Download Manager has been registered with a fake Serial Number
SVN图标不见了
理解createTrackbar函数
程序块结构
数组初始化
原文地址:https://www.cnblogs.com/xiexiaokui/p/573382.html
最新文章
Predicate和Consumer接口的使用
函数式编程
多并发下 SimpleDateFormat 出现错误
git 用法
MySQL8 Authentication plugin 'caching_sha2_password' cannot be loaded
springboot 测试
手写IOC框架
duboo 配置文件
springmvc 的原理分析
spring maven 包
热门文章
[head first php&mysql]读书笔记-上传文件吧(第五章)
[head first php&mysql]读书笔记-客户的反馈(第四章)
underscore源码解析(集合)
[读书笔记]高性能JS-加载执行
[读书笔记]高性能JS-编程实践
[读书笔记]高性能js-Ajax
[读书笔记]高性能js-界面快速响应
[读书笔记]高性能js-DOM优化
[读书笔记]高性能js-数据访问
web组件-日历控件
Copyright © 2011-2022 走看看