I want to execute this blow code to only checked rows in GvProducts
using Linq:
<ItemTemplate><asp:CheckBox ID="chkSel" runat="server" /></ItemTemplate>
Code:
double total = GvProducts.Rows.Cast<GridViewRow>()
.Sum(r => double.Parse(((TextBox)r.FindControl("txtQuantity")).Text) * double.Parse(((TextBox)r.FindControl("txtUnitprice")).Text));
I think we need more information to give a proper answer, to me it sound like this:
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));
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.