在哪种情况下,我们应该调用此方法将这个值绑定到网格视图之外? [英] in which event we should call this method for binding this value out of the grid view?

查看:86
本文介绍了在哪种情况下,我们应该调用此方法将这个值绑定到网格视图之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人可以帮忙吗?

在哪种情况下,我们应该调用此方法将这个值绑定到网格视图之外?

说明:
考虑在gridview中有两行... gridview的价格为& quanyiy ..这里的数量是可编辑的...当我单击编辑"时,数量已更新,但未显示在网格外...仅显示了最后一行..但在gridview中未显示其他一些行.... ........ pls帮助,如果有人知道..

Hi,

Can anyone help?

in which event we should call this method for binding this value out of the grid view?

description:
consider we have two rows in gridview...that gridview has price & quanyiy..here quantity is editable one...when i click edit it is updated but it is not showing on out of grid...only the last row had shown..but some other rows in gridview not shows............pls help if anyone know..

public void total()
    {
        float price1,totalprice;
        int quantity1;
        foreach (GridViewRow row in GridView1.Rows)
        {
            int pro_id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex][0]);
             price1 = dal.getprice(pro_id);
            quantity1 = dal.getquantity(pro_id);
             totalprice = quantity1*price1;
            lbltprice.Text = totalprice.ToString();
        }
    }

推荐答案

Al是正确的.
重新绑定网格时,从数据源重新获取数据时,计算值将丢失.
因此,您需要保留收集"的数据的某种字典,即与网格中的键值相关联的数量变量.

然后获取您的源数据,遍历对象,找到具有您的键值的对象,并更新数据源并重新绑定.
Al is right.
On the rebinding of your grid the calculated values will be lost as the data is refetched from the data source.
Therefore you need to keep some sort of dictionary of the data you have "collected" ie the quantity variables associated with a key value from the grid.

Then fetch your source data, loop through the objects find the ones that have your key values and update the datasource and rebind.


这篇关于在哪种情况下,我们应该调用此方法将这个值绑定到网格视图之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆