[英]How to keep the checkbox inside gridview checked based on certain condition?
[英]How to apply certain code when checkbox is checked in gridview using LINQ?
我想执行此打击代码,以仅使用Linq在GvProducts
检查行:
<ItemTemplate><asp:CheckBox ID="chkSel" runat="server" /></ItemTemplate>
码:
double total = GvProducts.Rows.Cast<GridViewRow>()
.Sum(r => double.Parse(((TextBox)r.FindControl("txtQuantity")).Text) * double.Parse(((TextBox)r.FindControl("txtUnitprice")).Text));
我认为我们需要更多信息才能给出正确的答案,这听起来像这样:
Checkbox oRb2 = (Checkbox )r.FindControl("rb_grid");double total = 0;
foreach (DataGridItem oItem in grid.Items)
{
if (oRb2.Checked == true)
{
total += GvProducts.Rows.Cast<GridViewRow>().Sum(r => double.Parse(((TextBox)r.FindControl("txtQuantity")).Text) * double.Parse(((TextBox)r.FindControl("txtUnitprice")).Text));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.