惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 赣江源

StreamInsight参考示例 Microsoft StreamInsight简介 GridView中的DataFormatString失效解决办法 - 赣江源 - 博客园 按照时间点还原数据库(SQL Server) 如何显示在线用户? ASP.NET中每个页面在Load之前调用公用函数 网站单点登录的实现思路 在服务器端提取ASP.NET控件输出的HTML 如何处理在IE7关闭时不出现选项卡提示 使用JavaScript控制UpdatePanel的更新 获取GridView单元格值的通用函数 如何在GridView将数字显示成金额格式或自定义格式? ASP.NET 2.0中使用XSLT的变化 在GridView表头显示排序方向 输出时清除GridView的Style ASP.NET实现打印的方法小结 提高ASP.NET性能的一点方法 asp.net的一些小技巧 route命令详解
利用AJAX实现DropDownList与GridView做实时更新
赣江源 · 2007-11-06 · via 博客园 - 赣江源

利用AJAX实现DropDownList与GridView做实时更新

本实例是完全用页面设置的方法,就可以达到的效果,不用编写任何后台代码,方便实用。需要先建立一个ASP.NET AJAX-Enabled Web Site,然后建立一个资料库,就可以使用了。

*.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ddlGridview_CS.aspx.cs" Inherits="ddlGridview_CS" %>

<!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>Test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
            <asp:ListItem Selected="True" Value="False">Active</asp:ListItem>
            <asp:ListItem Value="True">Complete</asp:ListItem>
        </asp:DropDownList>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="TaskID"
            DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None">
            <Columns>
                <asp:BoundField DataField="TaskID" HeaderText="TaskID" InsertVisible="False" ReadOnly="True"
                    SortExpression="TaskID" />
                <asp:BoundField DataField="TaskName" HeaderText="TaskName" SortExpression="TaskName" />
                <asp:CheckBoxField DataField="Complete" HeaderText="Complete" SortExpression="Complete" />
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <EditRowStyle BackColor="#999999" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
            SelectCommand="SELECT * FROM [Tasks] where Complete = @IsComplete">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="IsComplete" PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>

       </div>
    </form>
</body>
</html>