Search controls in the Asp.net pickup and formatting string DataGrid use footertemplate flexibly

Source: Internet
Author: User

Format a string
Dataformatstring = "{0: p}" // The percentage is automatically converted.
Dataformatstring = "{0: ####}" // retain two decimal places
Reference: http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/cpguide/html/cpconformattingoverview. asp

Search for controls in the DataGrid
In the databound event, use E. Item. cells [I]. controls [J], E. Item. findcontrol (""))
In the itemcommand event, the same as above or use datagrid1.items [0]. cells [0]. controls [0]). Note that the control type must be forcibly converted.
E. Item. cells [0]. Text can only get the boundcolumn value, and the value cannot be obtained in itemcommand.

If there is data binding during page initialization, write it in! Page. ispostback. Otherwise, data is reloaded every time you click a button, and the value of the input control may not be obtained.
Even though the front-end page is not refreshed when you use anthem.net, the CS code on the server is still executed in sequence according to the lifecycle of the page. of course, events in page_load will also be executed. therefore, you must use the hidden field, session, and other methods to handle data transmission and make good use of page. ispostback.

We recommend that you use the template column for editing, updating, and canceling. when itemcommand, cancelcommand, deletecommand, editcommand, and updatecommand are executed, the itemcommand event is triggered first and then their proprietary events are triggered. you can use the commandname of the button to conveniently implement the System Auto-edit button function. if the code is executed repeatedly on both sides, check whether there are oneditcommand and other events in the DataGrid tag, and bind the events again in initializecomponent. select either of the two.
Datalist. edititemindex = E. Item. itemindex; // assign a value first and then bind
Datalist. datasource = testdata;
Datalist. databind ();

Use footertemplate. if you want to display an empty row at the bottom of each page of the DataGrid and datalist control to add content, footertemplate is the best choice. when the datatable obtained from the data source in the DataGrid is empty, only the control in footertemplate is displayed. You can directly input data to add content. the operation is very convenient.

E. Item. cells [0]. Attributes. Add ("style", "cursor: hand;"); the hand icon is displayed when the mouse moves to the cell.

A mode window that cannot change the size is displayed, and its size is dynamically changed.
Function resize_dialog (T, L, W, H)
{
If (typeof (window. dialogheight )! = "# Ff0000 ")
{
Window. dialogtop = T + "PX ;"
Window. dialogleft = L + "PX ;"
Window. dialogheight = H + "PX ;"
Window. dialogwidth = W + "PX ;"
}
}
Function open_dialog (URLs, W, H)
{
Showmodaldialog (URLs, window, 'edge: raised; center: Yes; help: Yes; resizable: No; Status: No; dialogheight: '+ H + 'px; dialogwidth: '+ W + 'px ');
}

Tab multi label window display, imitation windows window style: http://bbs.blueidea.com/thread-2606562-1-1.html

Created by jecray


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.