0

enter code here我有以下函数可以将网格中特定列的总数相加。如何通过asp访问独立文本框中的最高GB?我试过这个,但没有成功。 Discovery Jobs ' > 谁能解释一下,谢谢。

double highestGB = 0;

protected void grd_JobTypeJT_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFooterItem)
    {
        footerItem["GB"].Controls.Add(new LiteralControl("Total: <br/>" + highestGB));
    }
    else if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;

    string GB = dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["GB"].ToString();
    double gbValue = Double.Parse(GB);
    totalPrice += gbValue;

    if (highestGB == 0 || highestGB < gbValue)
    {
        highestGB = gbValue;
    }

}
4

1 回答 1

1

你有一个看起来像页面级别的变量highestGB,所以将它分配给事件处理程序中的Text属性'TextBoxPage_Load

txtHighestGB.Text = highestGB.ToString();
于 2012-12-04T18:51:20.047 回答