lachmann
asked on
ASP.NET Gridview Editing -
The datasource for my gridview contains a column named "price". This value is an integer and represents the number of cents that the item costs. I want to display this to the user as a dollar value so I have the following:
Protected Sub gvDetails_RowDataBound(ByV al sender As Object, ByVal e As System.Web.UI.WebControls. GridViewRo wEventArgs ) Handles gvDetails.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim row As GridViewRow = e.Row()
Dim view As DataRowView = row.DataItem
Dim val As Integer
'price
Dim val As Integer = Integer.Parse(view("price" ))
row.Cells(5).Text = (val / 100).ToString("C")
End If
End Sub
This works fine to display the value to my user.
I am allowing editing in my gridview.
After I implement this formatting when I go to edit a row in the gridview the price field does not display in a textbox.
How do I keep my formatting and allow the user to edit this field inside the gridview.
Samples would be most helpful.
Protected Sub gvDetails_RowDataBound(ByV
If e.Row.RowType = DataControlRowType.DataRow
Dim row As GridViewRow = e.Row()
Dim view As DataRowView = row.DataItem
Dim val As Integer
'price
Dim val As Integer = Integer.Parse(view("price"
row.Cells(5).Text = (val / 100).ToString("C")
End If
End Sub
This works fine to display the value to my user.
I am allowing editing in my gridview.
After I implement this formatting when I go to edit a row in the gridview the price field does not display in a textbox.
How do I keep my formatting and allow the user to edit this field inside the gridview.
Samples would be most helpful.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.