GridView1 的textbox操作

 
<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;


        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值