asp.net gridview 鼠标悬浮提示信息
使用场景:
gridview绑定数据,某列数据太多,故超过一定字符,隐藏起来,同时鼠标移到指定列显示其明细信息;
知识点:
1,oderListTbl_DataBound事件中,添加,oderListTbl.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
2,web控件ToolTip属性,显示;
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="addairevent.aspx.cs" Inherits="web.airchange.addairevent" %> <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link href="/css/default.css" rel="stylesheet" type="text/css" />
<link href="/css/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/js/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="/js/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="/js/jquery.ui.position.js"></script>
<script type="text/javascript" src="/js/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="/js/jquery.ui.button.js"></script>
<script type="text/javascript" src="/js/jquery.ui.dialog.js"></script>
<script type="text/javascript" src="/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="/js/common.js?r=20140613"></script>
<script type="text/javascript" src="/js/jquery.validate.js"></script>
</head>
<body>
<form id="orderform" runat="server">
<div class="container">
<div class="title">
<span>【事件航变】<label style="color: purple;"></label></span>
</div>
<div class="content">
<div class="cPanel pbg">
<div class="detailPanel">
<table cellpadding="" cellspacing="" class="oderAdmin" width="80%">
<tbody>
<tr>
<th>
航司:
</th>
<td>
<asp:TextBox ID="txtairname" runat="server" MaxLength=""></asp:TextBox>
</td>
<th>
航班号:
</th>
<td>
<asp:TextBox ID="txtflightno" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<th>
出发:
</th>
<td>
<asp:TextBox ID="txtstartcity" runat="server" MaxLength=""></asp:TextBox>
</td>
<th>
到达:
</th>
<td>
<asp:TextBox ID="txtreachcity" runat="server" MaxLength=""></asp:TextBox>
</td>
</tr>
<tr>
<th>
航变原因:
</th>
<td>
<%-- <select id="ddlchangereason" name="ddlchangereason" runat="server">
<option value="">航班取消</option>
<option value="">航班延误</option>
<option value="">航班提前</option>
<option value="">航班号变更</option>
<option value="">舱位变更</option>
<option value="">直飞变中转</option>
<option value="">起降地变更</option>
<option value="">中转变直飞</option>
<option value="">航变回原订单时间</option>
<option value="">未知</option>
</select>--%>
<asp:DropDownList ID="ddlchangereason" runat="server">
<asp:ListItem Value="" Text=""></asp:ListItem>
<asp:ListItem Value="" Text="航班取消"></asp:ListItem>
<asp:ListItem Value="" Text="航班延误"></asp:ListItem>
<asp:ListItem Value="" Text="航班提前"></asp:ListItem>
</asp:DropDownList>
</td>
<th>
</th>
<td>
</td>
</tr>
<tr>
<th>
开始日期:
</th>
<td>
<asp:TextBox ID="txtrangestartdate" runat="server" rel="datetime"></asp:TextBox>
</td>
<th>
结束日期:
</th>
<td>
<asp:TextBox ID="txtrangeenddate" runat="server" rel="datetime"></asp:TextBox>
</td>
</tr>
<tr>
<th>
事件内容:
</th>
<td>
<asp:TextBox ID="txtremark" runat="server" rel="datetime" Height="135px" TextMode="MultiLine"
Width="456px" MaxLength=""></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="">
<asp:Button ID="btnsearch" runat="server" class="button button-primary" OnClick="btnsearch_Click"
Text="搜 索" />
<asp:Button ID="btnsave" class="button button-primary" runat="server" Text="保 存"
OnClick="btnsave_Click" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="cPanel">
<div class="detailPanel">
<asp:GridView ID="oderListTbl" GridLines="None" runat="server" CellSpacing="" BorderWidth=""
CellPadding="" class="oderListTbl" AutoGenerateColumns="False" OnDataBound="oderListTbl_DataBound"
OnRowDataBound="oderListTbl_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="航司">
<ItemStyle />
<ItemTemplate>
<%# Eval("airname")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="出发">
<ItemStyle />
<ItemTemplate>
<%# Eval("starcity")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="到达">
<ItemStyle />
<ItemTemplate>
<%# Eval("reachcity")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="航班号">
<ItemStyle Width="10%" />
<ItemTemplate>
<%# Eval("flightno")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="取消原因">
<ItemStyle />
<ItemTemplate>
<%# GetReasonDesc(Eval("changereason").ToString())%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="事件内容">
<ItemStyle Width="25%" />
<ItemTemplate>
<%--<%# SubStr(Eval("remark").ToString())%>--%>
<%# Eval("remark" )%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="备注">
<ItemStyle Width="15%" />
<ItemTemplate>
<%# Eval("msg")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="创建人">
<ItemStyle />
<ItemTemplate>
<%# Eval("createuserid")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="创建时间">
<ItemStyle />
<ItemTemplate>
<%# Eval("createtime")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div class="pager">
<webdiyer:AspNetPager ID="pager" CssClass="paginator" CurrentPageButtonClass="cpb"
runat="server" AlwaysShow="True" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
PageSize="" PrevPageText="上一页" ShowCustomInfoSection="Left" ShowInputBox="Never"
OnPageChanging="pager_PageChanging" CustomInfoTextAlign="Left" LayoutType="Table"
CustomInfoHTML="总条数:%RecordCount% 当前页数 %CurrentPageIndex% of %PageCount%">
</webdiyer:AspNetPager>
</div>
</div>
</div>
</div>
<div class="clr">
</div>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using web.code;
using System.Data;
using System.Text;
using webframework.model;
using webframework.bll;
using System.Data.SqlClient;
using System.Transactions; namespace web.airchange
{
public partial class addairevent : BasePage //System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PageRender();
}
} protected void btnsave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(ddlchangereason.SelectedValue))
{
Alert("请选择航班原因");
ddlchangereason.Focus();
return;
}
if (string.IsNullOrEmpty(txtstartcity.Text.Trim()) && string.IsNullOrEmpty(txtreachcity.Text.Trim()))
{
Alert("出发,到达 必须填写其中一项");
txtstartcity.Focus();
return;
}
if (string.IsNullOrEmpty(txtrangestartdate.Text.Trim()))
{
Alert("请选择开始日期");
txtrangestartdate.Focus();
return;
}
if (string.IsNullOrEmpty(txtrangeenddate.Text.Trim()))
{
Alert("请选择结束日期");
txtrangeenddate.Focus();
return;
} try
{
DateTime dtnow = DateTime.Now;
modelt_aireventmain model = new modelt_aireventmain();
model.airname = txtairname.Text.Trim().ToUpper();
model.changereason = Convert.ToInt32(ddlchangereason.SelectedValue);
model.createtime = dtnow;
model.createuserid = UserOnline.Current.UserName;
model.flightno = txtflightno.Text.Trim().ToUpper();
model.starcity = txtstartcity.Text.Trim().ToUpper();
model.reachcity = txtreachcity.Text.Trim().ToUpper();
model.remark = txtremark.Text.Trim().ToUpper();
model.rangestartdate = Convert.ToDateTime(txtrangestartdate.Text.Trim());
model.rangeenddate = Convert.ToDateTime(txtrangeenddate.Text.Trim());
model.msg = ""; List<modelt_aireventlink> list = new List<modelt_aireventlink>();
modelt_aireventlink m;
string ordernos = string.Empty;
string sql = "SELECT o.id,o.orderno,o.orderstate,o.shopname,o.orderfrom,j.id AS [journeyid],f.startcity,f.endcity,f.takeoffdate,f.carrier,f.flightno " +
"FROM t_order o INNER JOIN t_journey j ON o.id=j.orderid " +
"INNER JOIN t_flight f ON o.id=f.orderid AND j.id=f.journeyid " +
"WHERE takeoffdate>='" + txtrangestartdate.Text.Trim() + "' " +
"AND takeoffdate<'" + Convert.ToDateTime(txtrangeenddate.Text.Trim()).AddDays().ToString("yyyy-MM-dd") + "' ";
DataTable dt = code.SqlHelper.ExecuteDataTable(code.SqlHelper.ConnectionString, CommandType.Text, sql);
if (dt != null && dt.Rows.Count > )
{
foreach (DataRow row in dt.Rows)
{ if (((!string.IsNullOrEmpty(model.starcity) && model.starcity == row["startcity"].ToString().Trim())
|| string.IsNullOrEmpty(model.starcity))
&& ((!string.IsNullOrEmpty(model.reachcity) && model.reachcity == row["endcity"].ToString().Trim())
|| string.IsNullOrEmpty(model.reachcity))
&& ((!string.IsNullOrEmpty(model.airname) && model.airname == row["carrier"].ToString().Trim())
|| string.IsNullOrEmpty(model.airname))
&& ((!string.IsNullOrEmpty(model.flightno) && model.flightno.Contains(row["flightno"].ToString().Trim()))
|| string.IsNullOrEmpty(model.flightno)))
{
if (!ordernos.Contains(row["orderno"].ToString()))
ordernos += row["orderno"].ToString() + ",";
m = new modelt_aireventlink();
m.orderid = int.Parse(row["id"].ToString());
m.orderno = row["orderno"].ToString();
m.shopname = int.Parse(row["shopname"].ToString());
m.journeyid = int.Parse(row["journeyid"].ToString());
m.orderfrom = int.Parse(row["orderfrom"].ToString());
m.noticetime = Convert.ToDateTime("1900-01-01");
m.creattime = dtnow;
m.hbid = -;
list.Add(m);
}
}
ordernos = ordernos.TrimEnd(',');
}
int hbid = -;
bllaireventlink bllael = new bllaireventlink();
using (TransactionScope transaction = new TransactionScope())//使用事务
{
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionString))
{
//model.msg = string.Format("匹配订单数量:{0},航班数量:{1},订单号:{2}", list.Select(k => k.orderno).Distinct().ToList().Count, list.Count, string.Join(",", list.Select(k => k.orderno).Distinct().ToList()));
model.msg = string.Format("匹配订单数量:{0},航班数量:{1}", list.Select(k => k.orderno).Distinct().ToList().Count, list.Count);
hbid = new bllaireventmain().Add2(model, conn);
foreach (var l in list)
{
l.hbid = hbid;
bllael.Add1(l, conn);
}
}
transaction.Complete();//就这句就可以了。
Alert("添加成功");
}
PageRender(); }
catch (Exception ex)
{
Alert("出错:" + ex.Message);
}
}
private void PageRender()
{
StringBuilder sb = new StringBuilder(""); if (!string.IsNullOrEmpty(ddlchangereason.SelectedValue))
{
sb.Append(" and changereason=" + ddlchangereason.SelectedValue);
} if (!string.IsNullOrEmpty(txtstartcity.Text.Trim()))
{
sb.Append(" and starcity='" + txtstartcity.Text.Trim().ToUpper() + "'");
}
if (!string.IsNullOrEmpty(txtreachcity.Text.Trim()))
{
sb.Append(" and reachcity='" + txtreachcity.Text.Trim().ToUpper() + "'");
}
if (!string.IsNullOrEmpty(txtairname.Text.Trim()))
{
sb.Append(" and airname='" + txtairname.Text.Trim().ToUpper() + "'");
}
if (!string.IsNullOrEmpty(txtflightno.Text.Trim()))
{
sb.Append(" and flightno='" + txtflightno.Text.Trim().ToUpper() + "'");
}
if (!string.IsNullOrEmpty(txtrangestartdate.Text.Trim()))
{
sb.Append(" and rangestartdate>='" + txtrangestartdate.Text.Trim().ToUpper() + "'");
}
if (!string.IsNullOrEmpty(txtrangeenddate.Text.Trim()))
{
sb.Append(" and rangeenddate<'" + Convert.ToDateTime(txtrangeenddate.Text.Trim().ToUpper()).AddDays().ToString("yyyy-MM-dd") + "'");
} string sql = code.Q.GetTableByPager("t_aireventmain", "id,rangestartdate,rangeenddate,flightno,airname,remark,starcity,reachcity,changereason,createtime,createuserid,msg", "id desc", sb.ToString(), pager.CurrentPageIndex, base.PageSize);
sql += ";select count(1) from t_aireventmain where 1=1" + sb.ToString();
logclass.Info(sql);
try
{
DataSet ds = code.SqlHelper.ExecuteDataset(code.SqlHelper.ConnectionString, CommandType.Text, sql);
oderListTbl.DataSource = ds.Tables[];
oderListTbl.DataBind(); pager.PageSize = base.PageSize;
pager.RecordCount = int.Parse(ds.Tables[].Rows[][].ToString());
}
catch (Exception ex)
{
logclass.Debug("事件航班查询报错:" + ex.TargetSite + "===" + ex.Message);
}
} protected void btnsearch_Click(object sender, EventArgs e)
{
pager.CurrentPageIndex = ;
PageRender();
} protected void pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
pager.CurrentPageIndex = e.NewPageIndex;
PageRender();
} protected string GetReasonDesc(string reasoncode)
{
string result = "";
switch (reasoncode)
{
case "":
result = "航班取消";
break;
case "":
result = "航班延误";
break;
case "":
result = "航班提前";
break;
default:
break;
}
return result;
} protected void oderListTbl_DataBound(object sender, EventArgs e)
{
//数据太长 自动换行
oderListTbl.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
} protected void oderListTbl_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = ; i < e.Row.Cells.Count; i++)//获取总列数
{
////鼠标悬浮 显示列标题
//e.Row.Cells[i].Attributes.Add("title", oderListTbl.HeaderRow.Cells[i].Text.ToString().Trim());
//e.Row.Cells[i].ToolTip = oderListTbl.HeaderRow.Cells[i].Text.ToString().Trim(); //鼠标悬浮 显示列内容
if (oderListTbl.HeaderRow.Cells[i].Text.ToString().Trim() == "事件内容")
{
e.Row.Cells[i].ToolTip = (((DataRowView)e.Row.DataItem)["remark"]).ToString();
}
}
} } protected string SubStr(string str)
{
return str.Length <= ? str : str.Substring(, ) + "....";
}
}
}
其他:设置div的title值,提示信息
"<div style='overflow: hidden; white-space: nowrap; text-overflow: clip;width:90%;' title='" + data.startcitytext + "'>" + data.startcitytext + "</div>";
asp.net gridview 鼠标悬浮提示信息的更多相关文章
- 浅谈CSS和JQuery实现鼠标悬浮图片放大效果
对于刚刚学习网页前台设计的同学一定对图片的处理非常苦恼,那么这里简单的讲解一下几个图片处理的实例. 以.net为平台,微软的Visual Studio 2013为开发工具,当然前台技术还是采用CSS3 ...
- ArcGIS api fo silverlight学习三(利用ElementLayer实现鼠标悬浮弹出自定义窗体)
接着上一节继续学习,本节主要是利用ElementLayer实现鼠标悬浮弹出自定义窗体 参考博文:http://www.cnblogs.com/luxiaoxun/p/3322218.html 一.新建 ...
- IntelliJ设置鼠标悬浮提示和修改快捷键
IntelliJ设置鼠标悬浮提示和修改快捷键 设置鼠标悬浮提示 修改快捷键 进入设置菜单 删除原来的快捷键(注:你可以选择保留原来的快捷键,同时使用两个快捷键) Good Luck
- 一款很实用的jQuery鼠标悬浮有动画效果的响应式瀑布流插件
一款很实用的jQuery鼠标悬浮有动画效果的响应式瀑布流插件 在线预览 下载地址 实例代码 <!doctype html> <html lang="zh"> ...
- CSS/JS图片鼠标悬浮一道光闪过
看到有些网站logo鼠标悬浮上面的时候,会出现一道光,一闪而过,刚开始以为是gif图,已审查, 居然不是:现在就实现在这种效果: 先看看CSS实现的效果图: 看到没,就是这道刺眼的白光.... 啊 ...
- Asp.Net统一前后端提示信息方案
Asp.Net统一前后端提示信息方案 目录 要解决的问题 自定义XML 前端弹框的实现 后端弹框的实现 扩展和整合 示例代码(不完整)及示例截图 示例下载 要解决的问题 减少弹框前后端代码量 增强 ...
- 使用JS实现鼠标悬浮切换显示
实现的是在鼠标悬停在不同链接上,在同一位置切换显示想要显示的内容 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// ...
- css实现鼠标悬浮字体流光背景模糊效果
原文地址:→看过来 写在前面 有的时候感觉写点小玩意儿挺开心的,还能实践很多的小知识点,所以这次学着写了个有趣的鼠标悬浮模糊效果,只使用了css额. 效果图 源码地址→传送门 预览地址→传送门 小知识 ...
- 利用 :before :after伪类实现鼠标悬浮动画效果
1.最近在逛网站的时候,想找一下喜欢的鼠标悬浮效果,避免广告的嫌疑,直接放图了: 2.在实现的时候,如果在直接使用鼠标hover ,transform,进行过渡,不能达到想要的效果,因为同时只能触发一 ...
随机推荐
- jdk 编译器 对final字段的处理
class FinalTest{ void a(){ final int i=10; int j=10; } } stack=2, ...
- linux中模块的构建,传参,和printk函数的简单使用
静态编译,动态加载应用想访问内核需要通过系统调用 驱动:1.模块(打包,加入内核)2.内核机制3.操作硬件 在Kconfig里面配置menuconfig的时候,不同的类型会在图形化界面的终端显示不用的 ...
- 课前HTML基础
一..站点的建立 作用:用来归纳一个网站上所有的网页,素材以及他们之间的联系. 站点根文件夹的命名规则:必须是以英文或者下划线开头,后面可接数字和下划线,不可以使用中文和特殊字符. 二:创建HTML页 ...
- C#穷举
穷举: 穷举法的基本思想是根据题目的部分条件确定答案的大致范围, 并在此范围内对所有可能的情况逐一验证,直到全部情况验证完毕.若某个情况验证符合题目的全部条件,则为本问题的一个解:若全部情况验证后都 ...
- 附加数据库失败,操作系统错误 5:"5(拒绝访问。)"的解决办法
无法打开物理文件 XXX.mdf".操作系统错误 5:"5(拒绝访问.)". (Microsoft SQL Server,错误: 5120) 找到xxx.MDF与xx ...
- sass的安装与使用
一.SASS简介:SASS是一种使CSS的开发,变得简单和可维护开发工具. 二.安装和使用 2.1 SASS的安装: 安装sass之前首先需要安装ruby,ruby的安装可以直接在百度搜索安装,安装 ...
- iOS--cell的重用机制
对于像我们这样的初学者来说,cell重用机制是很难理解的内容,所以我们不一定非得理解,会用就行. cell的重用机制:当我们使用tableView时,系统只会创建屏幕中显示的cell的个数+1,当ce ...
- (转) PowerDesigner中Table视图同时显示Code和Name
PowerDesigner中Table视图同时显示Code和Name,像下图这样的效果: 实现方法:Tools-Display Preference
- UDP的使用
// // 该类管理所有的UDP发送 #import <Foundation/Foundation.h> #import "AsyncUdpSocket.h" @pr ...
- Python 基礎 - 文件操作_v2
嗯,那如何要把游標的位置給打印來? #!/usr/bin/env python3 # -*- coding:utf-8 -*- f = open('test', 'r') print(f.tell() ...