Link to home
Create AccountLog in
Avatar of lachmann
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(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) 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.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_4913559
Member_2_4913559
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Amandeep Singh Bhullar
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.