the GridView Data mouse move in display hint information _ Practical tips

Source: Internet
Author: User
Tags eval

Questions raised:

In development, if there is such a requirement, if the list control, such as a column in the GridView, shows the value of a calculated formula, then the demand comes, the mouse moves in the number, displays the calculation formula and process of the number, how to do?

Solution Analysis:

A general can use the Title property of a control to display a hint, but the style of displaying the information is not beautiful. We can then use a solution like this, which shows the effect as shown in the following illustration:

Detailed implementation steps:
1, download pop-up prompts box related JS package, download address:

2, will download the file decompression, said the entire Poptips folder into your project directory down, such as the JS folder.

3, in the page you need to introduce relevant documents, the most important is the following several documents:

<link href= ". /js/poptips/tip-yellow/tip-yellow.css "rel=" stylesheet "/> 
<script src=". /js/jquery-1.7.2.min.js "></script> 

4, the use of the GridView in the page, we can use the template column, as follows:

 <asp:gridview id=" GridView1 "onrowdatabound=" GridView1_RowDataBound "allowpaging=" True ' runat= ' server ' autogeneratecolumns= ' False ' onpageindexchanging= ' gridview1_pageindexchanging ' cellpadding = "4" cssclass= "Grid1" emptydatatext= "countless displays" pagesize= "width=" 99% "True" > headerstyle-wrap= Le backcolor= "#507CD1" font-bold= "True" forecolor= "white"/> <Columns> ... <asp:templatefield H eadertext= "Tce coal <br> (kg)" itemstyle-width= "100px" headerstyle-verticalalign= "Middle" headerstyle-horizontalalign= "Center" itemstyle-horizontalalign= "Center" > <ItemTemplate> <span Id= "ZBM" style= "color:blue; Cursor:pointer "runat=" server "title= ' <% #showZBMGS (Eval (" Dian "). ToString (), Eval ("Reli"). ToString (), Eval ("Yuanmei"). ToString (), Eval ("Tianrq"). ToString (), Eval ("Qiyou"). ToString (), Eval ("Chaiyou"). ToString (), Eval ("Zsny"). ToString ())%> ' ><%# Eval ("ZBM")%></spaN> </ItemTemplate> </asp:TemplateField> ... </Columns> </asp:GridView> 

5, the background CS code to add a method

 > #region the calculation formula of the folding coal shows that 2015-09-06///<summary>///Obtain the calculation formula of the standard coal,///</summ ary>///<param name= "Dian" ></param>///<param name= "Reli" ></param>///<param Nam E= "Yuanmei" ></param>///<param name= "Tianranqi" ></param>///<param name= "Qiyou" ></pa ram>///<param name= "chaiyou" ></param>///<param name= "Zsny" ></param>///<return  S></returns> public string Showzbmgs (String dian, String reli, String Yuanmei, String Tianranqi, String qiyou, String chaiyou, String Zsny) {Double ZBM = (double. Parse (Dian) * 0.1229) + (double. Parse (reli) * 0.0341) + (double. Parse (Yuanmei) * 0.7143) + (double. Parse (TIANRANQI) * 1.2143) + (double. Parse (qiyou) * 1.4714) + (double. Parse (chaiyou) * 1.4571) + (double. 
   Parse (ZSNY) * 1)) * 10; Zbmgs = "folded standard coal = electricity * 0.1229 + thermal * 0.0341 + RAW Coal * 0.7143 + natural gas * 1.2143 + petrol * 1.4714 + diesel * 1.4571+ Renewable Energy * 1</br>= "; Zbmgs + = Dian + "* 0.1229+" + reli + "* 0.0341+" + Yuanmei + "* 0.7143+" + Tianranqi + "* 1.2143+" + qiyou + "* 1.4714+ 
   "+ chaiyou +" * 1.4571+ "+ Zsny +" * 1</br>= "; 
   Zbmgs + + Math.Round (ZBM, 2); 
  return ZBMGS; } #endregion 

6. Next, when the page loads, apply this informational prompt, as shown in the following code:

$ (function () { 
  //Add information for control 2015-09-06 
  $CB = $ (' #<%=this. Gridview1.clientid%> '). Find (' span[id$= "ZBM"]); 
  $ ($CB). Poshytip (); 

The above is the entire content of this article, I hope to help you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.