开发环境:1、MOSS 2007 中文版 SP1

            2、QuickPart

            3、AJAX

功能简述:获取Gridview点击行的编号,Gridview,Button,Label

Gridview数据集,Label显示事件后获取的值,Button 事件按钮

 

代码如下:

<%@ Control Language="C#" AutoEventWireup="True" Codebehind="xmgl.ascx.cs" Inherits="TZBXMGL.xmgl"%>
 
<asp:ScriptManager ID="XMAjax" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel runat="server" ID="updateMain" UpdateMode="Conditional">
                  <Contenttemplate>
  <asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="8" AutoGenerateColumns="false"  EmptyDataText='"NO DATA!"'>
             <Columns>
        <asp:BoundField DataField="xmbh" HeaderText="盘源编号" />
        <asp:BoundField DataField="xmmc" HeaderText="项目名称"  />
        <asp:BoundField DataField="cplx" HeaderText="产品类型"  />
        <asp:BoundField DataField="xmgjjb" HeaderText="项目跟进级别"  />
               <asp:TemplateField>
            <ItemTemplate>
                <asp:Button ID="SelectButton" runat="server" Text="Button" OnClick="Button2_Click" CommandArgument='<%#Eval("xmbh")%>'/>
            </ItemTemplate> 
        </asp:TemplateField>
    </Columns>   
        </asp:GridView>

        <br />
        <br /><asp:Label ID="Label1" runat="server" text="显示"></asp:Label>
       </Contenttemplate>
</asp:UpdatePanel>

 

CS文件:

 

protected void Button2_Click(object sender, EventArgs e)
        {

           
          xmbh = ((Button)sender).CommandArgument.ToString().Trim();
            Label1.Text = xmbh;
           
        }

 

web.config文件

在pages节中 加入 enableEventValidation="false"