The GridView cell limits that users can only edit Chinese characters. The gridview Cell

Source: Internet
Author: User

The GridView cell limits that users can only edit Chinese characters. The gridview Cell

The results are as follows:

The source code is as follows:


How can a cell in the gridView be controlled? Up to 20 Chinese characters can be entered

1. In cs code: In the RowDataBound of the GridView, Remove () string is truncated for the item to be processed.
2. On the aspx page, the <ItemTemplate> data item template tag of the GridView binds Eval to the attributes of the text displayed in the control, and uses SubString as the final part to capture and display the text.
For example:
<Asp: TemplateField HeaderText = "Description">
<ItemTemplate>
<Asp: Label ID = "lbl" runat = "server" Text = '<% # Eval ("Description"). ToString ()> 12? Eval ("Description "). toString (). remove (10) + "... ": Eval (" Description "). toString () %> '> </asp: Label>
</ItemTemplate>
</Asp: TemplateField>

Can the gridview achieve this effect? Assignment during cell double-click

Yes.

When binding each row in the databound event of the gridview, you can add the specified event to the cell that follows.
Similar
Protected void gvRefList_RowDataBound (object sender, GridViewRowEventArgs e)
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
Label lbl_comp = e. Row. FindControl ("lbl_comp") as Label;
Lbl_comp... Attributes. Add ("","");
}
}

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.