[Gridview] Click Edit column. After modification, click Update to get the modified value.

Source: Internet
Author: User

 

In the gridview, click Edit column. After modification, click Update to obtain the modified value.

Select a value from the dropdownlist drop-down box. Click "save" and you will not be able to get the selected value. Instead, you will get the first value of this dropdownlist;

Solution:

Place the gridview_bind () function of the gridview binding function in the IF (! Ispostback.

Put the dropdownlist_bind function of dropdownlist in the IF (! Ispostback.

Cause:

Whether you click Update or dropdownlist in the gridview, and click Save, the page will be PostBack. If the binding function is not placed in the IF (! Ispostback), The gridview or dropdownlist will run the binding function again. As a result, the value of the row modified by the gridview is changed to the original value (before modification). The first item is selected by default in dropdownlist.

Summary:

Generally, when a page is loaded for the first time, the control to be bound is placed in if (! Ispostback.

Using system; using system. collections. generic; using system. text; using system. web; using system. web. ui; // some common JS calls // Add the new version Description: because the old version generally uses response. write (string MSG) is used to output JS scripts. js scripts output in this // mode are not included in the <HTML> MSG), does not change the XHTML structure, // does not affect the execution effect. /// In order to be backward compatible, the new version adopts the overload method. In the new version, an instance of the system. Web. UI. Page class is required. /// Creation Time: 2006-9-13 // Creator: Ma xianguang // author of the new version: Zhou Gong // modification date: 2007-4-17 // revised version of the web site: http://blog.csdn.net/zhoufoxcn/// public class JScript {# region old version ///// pop up JavaScript small window ///
/// Window information public static void alert (string message) {# region string JS = @ ""; httpcontext. current. response. write (JS ); # endregion} // the message box is displayed and switched to the new URL // message content // connection address public static void alertandredirect (string message, string tourl) {# region string
JS = ""; httpcontext. current. response. write (string. format (JS, message, tourl); # endregion} // return to the history page //-1/1 public static void gohistory (INT value) {# region string JS = @ ""; httpcontext. current. response. write (string. format (JS, value); # endregion
} // Close the current window // public static void closewindow () {# region string JS = @ ""; httpcontext. current. response. write (JS); httpcontext. current. response. end (); # endregion} // refresh the parent window // public static void refreshparent (string URL) {# region string JS = @"";
Httpcontext. current. response. write (JS); # endregion} // refresh to open the window // public static void refreshopener () {# region string JS = @ ""; httpcontext. current. response. write (JS ); # endregion} // open the new form of the specified size // address // width /// height /// header position // left position public static
Void openwebformsize (string URL, int width, int heigth, int top, int left) {# region string JS = @ ""; httpcontext. current. response. write (JS); # endregion} // redirect to the page specified by the URL // connection address public static void javascriptlocationhref (string URL) {# region string
JS = @ ""; JS = string. format (JS, URL); httpcontext. current. response. write (JS ); # endregion} // open the mode dialog box of the specified size and position // connection address // width // height /// distance from the upper position // /public static void showmodaldialogwindow (string webformurl, int width, int height, int top, int
Left) {# region string features = "dialogwidth:" + width. tostring () + "PX" + "; dialogheight:" + height. tostring () + "PX" + "; dialogleft:" + left. tostring () + "PX" + "; dialogtop:" + top. tostring () + "PX" + "; center: Yes; help = no; resizable: No; Status: No; scroll = yes ";
Showmodaldialogwindow (webformurl, features); # endregion} // the pop-up modal window // public static void showmodaldialogwindow (string webformurl, string features) {string JS = showmodaldialogjavascript (webformurl, features); httpcontext. current. response. write (JS );
} ///// Pop-up modal window ///////// public static string showmodaldialogjavascript (string webformurl, string features) {# region string JS = @ ""; return JS; # endregion} # endregion # New version of region ///// a small JavaScript window is displayed. // The window information is public static void alert (string
Message, page) {# region string JS = @ ""; // httpcontext. Current. response. Write (JS); If (! Page. clientscript. isstartupscriptregistered (page. getType (), "alert") {page. clientscript. registerstartupscript (page. getType (), "alert", JS) ;}# endregion }//////
The message box is displayed and switched to the new URL // message content // connection address public static void alertandredirect (string message, string tourl, page) {# region string JS = ""; // httpcontext. current. response. write (string. format (JS, message, tourl); If (! Page. clientscript. isstartupscriptregistered (page. GetType (),
"Alertandredirect") {page. clientscript. registerstartupscript (page. getType (), "alertandredirect", String. format (JS, message, tourl);} # endregion} // return to the history page //-1/1 public static void gohistory (INT value, page) {# region string JS = @"";
// Httpcontext. Current. response. Write (string. Format (JS, value); If (! Page. clientscript. isstartupscriptregistered (page. getType (), "gohistory") {page. clientscript. registerstartupscript (page. getType (), "gohistory", String. format (JS, value) ;}# endregion}
///////// Close the current window /////// public static void closewindow () // {// # region // string JS = @ ""; // httpcontext. current. response. write (JS); // httpcontext. current. response. end (); // # endregion //} // refresh the parent window // public static void refreshparent (string
URL, page) {# region string JS = @ ""; // httpcontext. Current. response. Write (JS); If (! Page. clientscript. isstartupscriptregistered (page. GetType (), "refreshparent") {page. clientscript. registerstartupscript (page. GetType (), "refreshparent", JS);} # endregion
} ///// Refresh and open the window // public static void refreshopener (page) {# region string JS = @ ""; // httpcontext. current. response. write (JS); If (! Page. clientscript. isstartupscriptregistered (page. GetType (), "refreshopener") {page. clientscript. registerstartupscript (page. GetType (),
"Refreshopener", JS );} # endregion} // open the new form of the specified size // address // width /// height /// header position // left position public static void openwebformsize (string URL, int width, int heigth, int top, int left, page) {# region string JS = @ ""; // httpcontext. current. response. write (JS );
If (! Page. clientscript. isstartupscriptregistered (page. getType (), "openwebformsize") {page. clientscript. registerstartupscript (page. getType (), "openwebformsize", JS) ;}# endregion }///// redirect to the URL-based page //// connection address public static void javascriptlocationhref (string
URL, page) {# region string JS = @ ""; JS = string. format (JS, URL); // httpcontext. current. response. write (JS); If (! Page. clientscript. isstartupscriptregistered (page. GetType (), "javascriptlocationhref") {page. clientscript. registerstartupscript (page. GetType (),
"Javascriptlocationhref", JS );} # endregion} // open the mode dialog box of the specified size and position // connection address // width // height /// distance from the upper position // /public static void showmodaldialogwindow (string webformurl, int width, int height, int top, int left, page) {# region string features = "dialogwidth :"
+ Width. tostring () + "PX" + "; dialogheight:" + height. tostring () + "PX" + "; dialogleft:" + left. tostring () + "PX" + "; dialogtop:" + top. tostring () + "PX" + "; center: Yes; help = no; resizable: No; Status: No; scroll = yes"; showmodaldialogwindow (webformurl, features,
Page); # endregion} // the pop-up modal window // public static void showmodaldialogwindow (string webformurl, string features, page) {string JS = showmodaldialogjavascript (webformurl, features); // httpcontext. current. response. write (JS); If (! Page. clientscript. isstartupscriptregistered (page. GetType (),
"Showmodaldialogwindow") {page. clientscript. registerstartupscript (page. getType (), "showmodaldialogwindow", JS );}} ///////// pop-up modal window //////// // public static string showmodaldialogjavascript (string webformurl, string features )//
{// # Region // string JS = @ ""; // return JS; // # endregion //} # endregion}

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.