GridView.RowUpdating 事件

下面的示例演示如何使用 RowUpdating 事件在更新数据源之前对用户提供的所有值进行 HTML 编码。

C#
<%@ Page language= "C#" %>

"-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



  "server">
    GridView RowUpdating Example


   
"form1" runat= "server">

     

GridView RowUpdating Example



     
     
     
     
      "CustomersGridView"
        datasourceid= "CustomersSqlDataSource"
        autogeneratecolumns= "true"
        autogenerateeditbutton= "true"
        allowpaging= "true"
        datakeynames= "CustomerID"
        onrowupdating= "CustomersGridView_RowUpdating" 
        runat= "server">
     


     
     
     
     
      "CustomersSqlDataSource" 
        selectcommand= "Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        updatecommand= "Update Customers SET CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country WHERE (CustomerID = @CustomerID)"
        connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat= "server">
     


   

 



下面的示例演示如何使用 RowUpdating 事件在以编程方式设置数据源时更新数据源对象中的值。

C#
<%@ Page Language= "C#" %>
<%@ Import Namespace= "System.Data" %>

"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




"server">
    GridView example


   
"form1" runat= "server">
   


      "TaskGridView" runat= "server"
        AutoGenerateEditButton= "True"
        OnRowEditing= "TaskGridView_RowEditing"        
        OnRowCancelingEdit= "TaskGridView_RowCancelingEdit"
        OnRowUpdating= "TaskGridView_RowUpdating">
     


   

   


你可能感兴趣的:(C#编程)