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
查看全文
相关阅读:
我的Ajax之旅(一):不能加载'AjaxControlToolkit'。。。拒绝访问
网络编程(一):用C#下载网络文件的2种方法
Locks
Threads
C语言中函数名和struct名可以重名!
使用#include <pthread.h>
APUE Chapter 7 (2)main函数的参数
Creating a shared and static library with the gnu compiler [gcc][转]
Signals
APUE Chapter 7(3) – Memory layout of a C program
原文地址:https://www.cnblogs.com/xiexiaokui/p/573382.html
最新文章
铁路客户服务中心网站
程序21、程序22和程序23
程序19和程序20
程序16和程序17
程序27、程序28和程序29
栈的应用
在不兼容IE中推动发展
jquery 时间段
javascript 栈 Stack
程序24和程序25
热门文章
jquery datepicker
java编程思想chapter3
myeclipse转成eclipse(转)
ACTIVEMQ设置Timestamp和jms简介
Java project + wsdl2java
java编程思想chapter1
java编程思想chapter2
C#获取网页内容的三种方式
单机程序的数据处理:Access + DataSet + Linq
C#程序员学习使用WinDbg
Copyright © 2011-2022 走看看