获取gridview模板列textbox的值失败
前台图片和代码:<Columns><asp:BoundFieldDataField="GoodsName"HeaderText="商品名称"ControlStyle-Wi...
前台图片和代码:
<Columns>
<asp:BoundField DataField="GoodsName" HeaderText="商品名称" ControlStyle-Width="200" />
<asp:BoundField DataField="GoodsTypeName" HeaderText="所属类别" ControlStyle-Width="30" />
<asp:BoundField DataField="GoodsPrice" HeaderText="商品价格" ControlStyle-Width="30" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" ControlStyle-Width="30">
<ItemStyle Font-Underline="False" />
<ControlStyle Font-Underline="False" ForeColor="Black" />
</asp:CommandField>
<asp:TemplateField HeaderText="数量">
<ItemTemplate>
<asp:TextBox ID="GoodsCount" runat="server" Text='<%# Bind("Number") %>' Width="30" OnTextChanged="TextChanged" AutoPostBack="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
后台获取值:
double price = Convert.ToDouble(gvOrderInfo.Rows[i].Cells[2].Text.Trim());
double count = Convert.ToDouble((gvOrderInfo.Rows[i].FindControl("GoodsCount")).Text.Trim());
//double count = Convert.ToDouble((gvOrderInfo.Rows[i].Cells[4].Controls[0]).Text.Trim());
price获取没问题,但两个count获取部分都提示: “System.Web.UI.Control”并不包含“Text”的定义
急:求解啊,被卡住了,进行不下去了 展开
<Columns>
<asp:BoundField DataField="GoodsName" HeaderText="商品名称" ControlStyle-Width="200" />
<asp:BoundField DataField="GoodsTypeName" HeaderText="所属类别" ControlStyle-Width="30" />
<asp:BoundField DataField="GoodsPrice" HeaderText="商品价格" ControlStyle-Width="30" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" ControlStyle-Width="30">
<ItemStyle Font-Underline="False" />
<ControlStyle Font-Underline="False" ForeColor="Black" />
</asp:CommandField>
<asp:TemplateField HeaderText="数量">
<ItemTemplate>
<asp:TextBox ID="GoodsCount" runat="server" Text='<%# Bind("Number") %>' Width="30" OnTextChanged="TextChanged" AutoPostBack="True"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
后台获取值:
double price = Convert.ToDouble(gvOrderInfo.Rows[i].Cells[2].Text.Trim());
double count = Convert.ToDouble((gvOrderInfo.Rows[i].FindControl("GoodsCount")).Text.Trim());
//double count = Convert.ToDouble((gvOrderInfo.Rows[i].Cells[4].Controls[0]).Text.Trim());
price获取没问题,但两个count获取部分都提示: “System.Web.UI.Control”并不包含“Text”的定义
急:求解啊,被卡住了,进行不下去了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询