<script language="javascript" type="text/javascript">
function comti()
{
var aaa="";
var table = document.getElementById("<%=GridView1.ClientID %>");
var rowIndex = 0 ;
for(var i=1;i<table.rows.length;i++)
{
var str = table.rows[i].cells[0].getElementsByTagName("input")[0].value;
if(str!="")
{
aaa=aaa +","+ str;
}
}
alert(aaa);
}
</script>
</head>
<body >
<form id="form1" runat="server">
<center>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div >
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3"
AutoGenerateColumns="False"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle BorderColor="#9999FF" BorderWidth="2px" />
<Columns>
<asp:TemplateField HeaderText="类别名称">
<ItemTemplate>
<asp:TextBox ID="txtLeiming" runat="server" OnTextChanged="onchange" AutoPostBack="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="nw">
<ItemTemplate>
<asp:TextBox ID="MyTextBox" runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6699FF" BorderColor="#003300" BorderWidth="1px" />
</asp:GridView>
<asp:Button ID="Button1" runat="server" OnClientClick="comti()" οnclick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</center>
</form>
</body>
protected void onchange(object sender, EventArgs e)
{
// ClientScript.RegisterStartupScript(this.GetType(), "", "alert(' dddd');", true);
//ScriptManager.RegisterClientScriptBlock(UpdatePanel1,
// this.GetType(), "click", "alert('ssss')", true);
TextBox t = (TextBox)sender;
GridViewRow drv = (GridViewRow)t.NamingContainer;
int rowIndex = drv.RowIndex;
((TextBox)GridView1.Rows[drv.RowIndex].FindControl("MyTextBox")).Text = t.Text;
}