利用ASP.NET AJAX实现表格更新程序

今天看了一个网站http://aspadvice.com/blogs/azamsharp/archive/2007/06/28/Edit-GridView-Using-CheckBoxes.aspx,自己做了一个小程序,表格更新程序,主要功能为使用CheckBoxe允许编辑GridView行,并且能够保存修改的信息
具体程序如下:
<%@ 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
posted @   Leepy  阅读(1153)  评论(3编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示