日期:2014-05-18 浏览次数:20896 次
GridView1.Rows[0].Cells[0].FindControl("textbox1");
------解决方案--------------------
我用的是datagrid。。
我接触web也没几天。。感觉和Gridview差不多,说错了勿喷。。
<asp:DataGrid runat="server" ID="Dg_BusiStore" AllowCustomPaging="True" AutoGenerateColumns="False" AllowSorting="True" CellPadding="4" DataKeyField="Id" BackColor="White" BorderColor="#AED0EA" BorderStyle="None" BorderWidth="1px" Width="100%" CssClass="ui-widget gridview" onitemcommand="Dg_BusiStore_ItemCommand"> <Columns> <asp:TemplateColumn HeaderText="盘点数量" HeaderStyle-Width="100px"> <ItemTemplate> <asp:TextBox ID="Txt_CheckStorage" runat="server" Style="text-align: right" MaxLength="8" Text='<%#Eval("CheckQuantity") %>' Width="100px"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="盘点金额" HeaderStyle-Width="100px"> <ItemTemplate> <asp:TextBox ID="Txt_CheckAmount" runat="server" Style="text-align: right" ReadOnly="true" Enabled="false" AutoPostBack="false" Width="100px" Text='<%#Eval("CheckAmt") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemTemplate> <asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="Save" Text="保存" CssClass="fg-button ui-state-default ui-corner-all" /> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> protected void Dg_BusiStore_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Save") { string Id = Dg_BusiStore.DataKeys[e.Item.ItemIndex].ToString(); DataGridItem Dg_Item = Dg_BusiStore.Items[e.Item.ItemIndex]; TextBox Txt_Storage = Dg_Item.FindControl("Txt_CheckStorage") as TextBox; if (string.IsNullOrEmpty(Id)) { this.Master.ShowErrorDialog("没有找到盘点信息,保存盘点数量失败"); return; } int intStorage; if (!int.TryParse(Txt_Storage.Text.Trim(), out intStorage)) { this.Master.ShowErrorDialog("你输入的“盘点数量”有误,请输入正整数"); return; } if (!UpdateCheckStorage(Id, intStorage)) { this.Master.ShowNotice("保存盘点数量失败");