Methods for intercepting the gridview string in

Source: Internet
Author: User

First, set the style on the foreground
Copy codeThe Code is as follows:
<Style type = "text/css">
. Listover150
{
Width: 150px;
Text-align: left;
Overflow: hidden;
Text-overflow: ellipsis; // The ellipsis (...) for super-long settings.
White-space: nowrap;
}
</Style>

Then, set RowDataBind in the background GridView.

, With a few words to change the style settings of the mouse movement

 Copy codeThe Code is as follows:
// List Loading
Protected void gv_showReport_RowDataBound (object sender, GridViewRowEventArgs e)
{

If (e. Row. RowType = DataControlRowType. DataRow)
{

// Restore the background color when you move the mouse away.
E. Row. Attributes. Add ("onmouseout", "this. style. backgroundColor = c ");
E. Row. Attributes. Add ("onmouseover", "c = this. style. backgroundColor; this. style. backgroundColor = '# f4fb '");
E. Row. Attributes. Add ("onclick", "this. style. backgroundColor = '# e2eaf1 '");
}
If (e. Row. RowType = DataControlRowType. Header)
{
E. Row. Attributes. Add ("style", "background-image: url ('../images/grid3-hrow.gif ')");
}
If (e. Row. RowType = DataControlRowType. DataRow)
{
// Set the length of the Request reason string.
String strDISC = e. Row. Cells [4]. Text. Trim ();
E. Row. Cells [4]. Text = "<div class =/" listover150/">" + strDISC + "</div> ";
E. Row. Cells [4]. ToolTip = strDISC; // move the cursor to display all

// Set the length of the approval remarks string
String str = e. Row. Cells [7]. Text. Trim ();
E. Row. Cells [7]. Text = "<div class =/" listover150/">" + str + "</div> ";
E. Row. Cells [7]. ToolTip = str;

}
}
 

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: info-contact@alibabacloud.com 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.