使用场景:

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>
&nbsp;
</th>
<td>
&nbsp;
</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="搜 索" />
&nbsp;&nbsp;
<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 鼠标悬浮提示信息的更多相关文章

  1. 浅谈CSS和JQuery实现鼠标悬浮图片放大效果

    对于刚刚学习网页前台设计的同学一定对图片的处理非常苦恼,那么这里简单的讲解一下几个图片处理的实例. 以.net为平台,微软的Visual Studio 2013为开发工具,当然前台技术还是采用CSS3 ...

  2. ArcGIS api fo silverlight学习三(利用ElementLayer实现鼠标悬浮弹出自定义窗体)

    接着上一节继续学习,本节主要是利用ElementLayer实现鼠标悬浮弹出自定义窗体 参考博文:http://www.cnblogs.com/luxiaoxun/p/3322218.html 一.新建 ...

  3. IntelliJ设置鼠标悬浮提示和修改快捷键

    IntelliJ设置鼠标悬浮提示和修改快捷键 设置鼠标悬浮提示 修改快捷键 进入设置菜单 删除原来的快捷键(注:你可以选择保留原来的快捷键,同时使用两个快捷键) Good Luck

  4. 一款很实用的jQuery鼠标悬浮有动画效果的响应式瀑布流插件

    一款很实用的jQuery鼠标悬浮有动画效果的响应式瀑布流插件 在线预览 下载地址 实例代码 <!doctype html> <html lang="zh"> ...

  5. CSS/JS图片鼠标悬浮一道光闪过

    看到有些网站logo鼠标悬浮上面的时候,会出现一道光,一闪而过,刚开始以为是gif图,已审查, 居然不是:现在就实现在这种效果: 先看看CSS实现的效果图: 看到没,就是这道刺眼的白光....   啊 ...

  6. Asp.Net统一前后端提示信息方案

    Asp.Net统一前后端提示信息方案   目录 要解决的问题 自定义XML 前端弹框的实现 后端弹框的实现 扩展和整合 示例代码(不完整)及示例截图 示例下载 要解决的问题 减少弹框前后端代码量 增强 ...

  7. 使用JS实现鼠标悬浮切换显示

    实现的是在鼠标悬停在不同链接上,在同一位置切换显示想要显示的内容 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// ...

  8. css实现鼠标悬浮字体流光背景模糊效果

    原文地址:→看过来 写在前面 有的时候感觉写点小玩意儿挺开心的,还能实践很多的小知识点,所以这次学着写了个有趣的鼠标悬浮模糊效果,只使用了css额. 效果图 源码地址→传送门 预览地址→传送门 小知识 ...

  9. 利用 :before :after伪类实现鼠标悬浮动画效果

    1.最近在逛网站的时候,想找一下喜欢的鼠标悬浮效果,避免广告的嫌疑,直接放图了: 2.在实现的时候,如果在直接使用鼠标hover ,transform,进行过渡,不能达到想要的效果,因为同时只能触发一 ...

随机推荐

  1. jenkins配置

    自动化测试机器172,27.14.22   IP 一.jenkins要先登录——>点击JCF_Automation——>点击左边配置 二.环境变量赋值就不会把进程杀掉

  2. 【其他】win7创建wifi热点共享给手机使用

    出门在外,有时候网络有诸多不便,需要用笔记本创建wifi热点给手机用:本人测试xp怎么配置都不好使,但win7有可行的方案,不依赖第三方软件. 详述如下: 场景一:win7 + A(PC机)(用无线连 ...

  3. ccs3

    [ 布局 Layout] display:none | intel |block | list-item | inline-block| [ 取值:] onne:隐藏对象.与visibility属性的 ...

  4. 《深入浅出Node.js》第6章 理解 Buffer

    @by Ruth92(转载请注明出处) 第6章 理解 Buffer ✁ 为什么需要 Buffer? 在 Node 中,应用需要处理网络协议.操作数据库.处理图片.接收上传文件等,在网络流和文件的操作中 ...

  5. MySQL分布式集群之MyCAT(转)

    原文地址:http://blog.itpub.net/29510932/viewspace-1664499/ 隔了好久,才想起来更新博客,最近倒腾的数据库从Oracle换成了MySQL,研究了一段时间 ...

  6. Java编程经验——Long等包装类型判断

    int等基本数据类型的值是可以通过=或者!=进行比较的,但是对于Long等包装类型想比较其和某个值是否相等是不能通过=或者!=来比较的,那究竟要怎么样进行比较呢? if (null != projec ...

  7. overflow:hidden清楚浮动的影响

    在网页布局中有时会遇到这种情况: 如果左边用<dt>,右边用<dd>,放在一行显示,<dt>要设置float:left,这个应该都知道,问题是,第一行这样做没有问题 ...

  8. 【转】 TechED2010与我(三) —— 初识云计算

    作者用到的比喻很好. 网址:TechED2010与我(三) -- 初识云计算 初识云计算最近"云计算"被炒的很热,但是由于工作重点主要是做WinForm的控件开发,对云计算的接触比 ...

  9. wordpress导入模板数据

    主题安装完成以后,如果有主题的DEMO数据(xml格式的)的话可以导入,导入后该有的页面与分类文章等等都会有了,这样子会节省很多时间,导入后只需要更改对应的页面与分类就可以了. 导入方法: 1. 在后 ...

  10. NodeOS操作系统

    导读 我想大多数人听说过 Node.js,但是你听说过 NodeOS 吗?一个用 Node.js 写的操作系统,NodeOS 用 Linux 内核来处理各种底层任务,比如硬件通讯什么的,但是除此之外, ...