我希望能够输入一个值数量文本框,然后:如何乘两个GridView的列到一个
- 乘以它的“单位平方英尺的”该值和结果存储在“小计“
- 总和每个小计并将结果存入 ”总计“
这是我到目前为止有:
<asp:GridView runat="server" ID="gridViewBuildOfficeSpace" AllowPaging="false"
AllowSorting="false" AutoGenerateDeleteButton="false"
AutoGenerateEditButton="false" AutoGenerateSelectButton="false"
AutoGenerateColumns="false" ShowFooter="true"
onrowdatabound="gridViewBuildOfficeSpace_RowDataBound">
<Columns>
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Size" HeaderText="Size" />
<asp:BoundField DataField="Dimensions" HeaderText="Dimensions" />
<asp:TemplateField HeaderText="Unit Square Foot">
<ItemTemplate>
<asp:Label runat="server" ID="unitSquareFootLabel" Text='<%# Eval("UnitSquareFoot") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" >
<ItemTemplate>
<asp:TextBox AutoPostBack="true" ID="gridviewQuantityItem" runat="server"/>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label12" Text="Total Size: " runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SubTotal">
<ItemTemplate>
<asp:Label ID="gridViewItemSubTotal" runat="server" />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="totalSizeDisplayLabel" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
代码背后:
protected void gridViewBuildOfficeSpace_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < gridViewBuildOfficeSpace.Rows.Count; i++)
{
gridViewBuildOfficeSpace.Rows[i].Cells[5].Text = Convert.ToString(Convert.ToDouble(gridViewBuildOfficeSpace.Rows[i].Cells[3].Text)*Convert.ToDouble(gridViewBuildOfficeSpace.Rows[i].Cells[4].Text));
}
}
我尝试使用文本框,OnTextChanged内,然后试图找到有关把它们变成整数和它们相乘并显示值到标签的控制,但我要么得到关于空引用unitSquareFootLabel。
但随着上面的代码我得到输入字符串是不是在正确的格式。
我该怎么做?
需要更多的细节布鲁。请描述您收到的错误,您看过的问题(以及失败的原因)。 – Mathemats 2015-03-30 23:24:51
是我,还是问题的标题是误导性的。将两个网格乘以一个?那意味着两个网格?这没有什么区别吗? – Aizen 2015-03-31 00:04:39