DataBound和RowDataBound [英] DataBound and RowDataBound

查看:73
本文介绍了DataBound和RowDataBound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网格视图中,DataBound事件和RowDataBound事件之间的实际区别是什么?

What is the actual difference between DataBound event and RowDataBound event in a grid view?
Is it necessary to use both of them to bind the data or one is enough?

推荐答案


在呈现GridView控件之前,必须将控件中的每一行绑定到数据源中的一条记录.当数据行(由GridViewRow对象表示)绑定到GridView控件中的数据时,引发 RowDataBound 事件.这样,您就可以提供一种事件处理方法,该方法可以在发生此事件时执行自定义例程,例如修改绑定到该行的数据的值.
参考:
MDSN:GridView.RowDataBound事件 [ ^ ]
MDSN:GridView.OnRowDataBound方法 [ ^ ]

当服务器控件绑定到数据源后要执行某些操作时,我们将使用gridview DataBound 事件.例如,在绑定之后,我们可能想在网格底部显示一些文本,或者我们可能想计算列的总值.
MSDN:GridView.DataBind方法 [ MSDN:GridView.DataBind方法() [ ^ ]

祝一切顺利.
--Amit
Hi,
Before the GridView control can be rendered, each row in the control must be bound to a record in the data source. The RowDataBound event is raised when a data row (represented by a GridViewRow object) is bound to data in the GridView control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs.
Refer :
MDSN : GridView.RowDataBound Event[^]
MDSN : GridView.OnRowDataBound Method[^]

We use gridview DataBound event when we want to do certain things after the server controls bind to the datasource. For example after the binding we may want to display some text at the bottom of the grid or we might want to calculate the total value of a column.
MSDN : GridView.DataBind Method[^]
MSDN : GridView.DataBind Method ()[^]

All the best.
--Amit


这篇关于DataBound和RowDataBound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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