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

  • 相关阅读:
    Vue 2.x windows环境下安装
    VSCODE官网下载缓慢或下载失败 解决办法
    angular cli 降级
    Win10 VS2019 设置 以管理员身份运行
    XSHELL 连接 阿里云ECS实例
    Chrome浏览器跨域设置
    DBeaver 执行 mysql 多条语句报错
    DBeaver 连接MySql 8.0 报错 Public Key Retrieval is not allowed
    DBeaver 连接MySql 8.0报错 Unable to load authentication plugin 'caching_sha2_password'
    Linux系统分区
  • 原文地址:https://www.cnblogs.com/xiexiaokui/p/573382.html
Copyright © 2011-2022 走看看