具体程序如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultipleUpdateDemo.aspx.cs" Inherits="MultipleUpdateDemo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/C#" runat="server">
[System.Web.Services.WebMethod]
public static bool UpdateText(string categoryName, string description, string Id)
{
string conectionString = "Data Source=(local);Initial Catalog=Northwind;User ID=sa;Password=sa";
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(conectionString);
conn.Open();
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("UPDATE Categories SET CategoryName = '" + categoryName + "', Description = '" + description + "' WHERE CategoryID = " + Id, conn);
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
</script>
<script type="text/javascript">
function disableGridViewTextBoxes()
{
var gvControl = document.getElementById("gvCategories");
var inputElements = gvControl.getElementsByTagName("INPUT");
for( i = 0;i < inputElements.length; i++)
{
if(isTextBox(inputElements[i]))
{
inputElements[i].disabled =<span style="COLOR: #000000; BACKGROUND-COLOR: %2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/C#" runat="server">
[System.Web.Services.WebMethod]
public static bool UpdateText(string categoryName, string description, string Id)
{
string conectionString = "Data Source=(local);Initial Catalog=Northwind;User ID=sa;Password=sa";
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(conectionString);
conn.Open();
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("UPDATE Categories SET CategoryName = '" + categoryName + "', Description = '" + description + "' WHERE CategoryID = " + Id, conn);
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
</script>
<script type="text/javascript">
function disableGridViewTextBoxes()
{
var gvControl = document.getElementById("gvCategories");
var inputElements = gvControl.getElementsByTagName("INPUT");
for( i = 0;i < inputElements.length; i++)
{
if(isTextBox(inputElements[i]))
{
inputElements[i].disabled =<span style="COLOR: #000000; BACKGROUND-COLOR: %2