PDA

View Full Version : سوال: فوری RowDataBound event in gridview



sara29
دوشنبه 02 شهریور 1388, 18:15 عصر
سلام دوستان .من یه برنامه دارم که از gridview استفاده می کنه (در فرم) و از cellformatting event استفاده می کنه :

Private Sub DataGridV3_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEve ntArgs) Handles DataGridV3.CellFormatting

e.Value = FormatCurrency(Me.DataGridV3.Item(e.ColumnIndex, e.RowIndex).Value)


متد FormatCurrency ارقام هر ستون که مقادیر مالی نشون میده با کاما جدا می کنه.
حالا من می خوام این gridview در صفحات asp.net ایجاد کنم. من برای فرمت مقادیر از rowDataBound event استفاده کردم:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim r As System.Data.DataRowView
If (e.Row.RowType = DataControlRowType.DataRow) Then
r = CType(e.Row.DataItem, System.Data.DataRowView)

r.Row.Item(1)=
FormatCurrency(r.Row.ItemArray.GetValue(1 )
End Sub

مشکل اینجاست که وقتی متد فرمت مقدار موردنظر مثلا 2،243 برمیگردونه مقداری که در خط آخر در آیتم ذخیره میشه به decimal تبدیل میشه و کاما ها را حذف می کنه و در نتیجه عدد 2243 در جدول دیده می شه. شما چه روشی پیشنهاد می کنید