AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 RowEditing in a Gridview
Posted by Kate Tate on  10/11/2007 5:37:10 PM Category: Asp.Net 2.0
Add to my favorites
Email to friend
Hello! I am a newbie and need some help. I am working in Asp.Net 2.0 and using VB.

I have a grid view that is set to edit and upon edit of one text field it runs a calculation then puts the results of that equation into the text box of another field upon "update". It works great on my first page, but when I copied and pasted it into another page it doesn't work quite the same.

It will update the info on the "miles" but not run the calculation on the "amount" changing the amount to the results of the calculation. Ironically and irritatingly enough, it will run the calculation if upon hitting the edit you tab to the "amount" field and hit the delete button on the keyboard. It will then update perfectly. However, if you leave the original amount in, hit the space bar or put in a "0" it will not perform the calculation.

Any and all suggestions would be extremely welcome!

Thanks

Kate

Here is the code:

Protected Sub gvAuthApproval_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvAuthApproval.RowUpdating

'This allows updating of the miles in the gridview and recalculating the amount.

Dim amount As Decimal
Dim txtMiles As TextBox = CType(gvAuthApproval.Rows(e.RowIndex).FindControl("txtMiles"), TextBox)
Dim txtAmount As TextBox = CType(gvAuthApproval.Rows(e.RowIndex).FindControl("txtAmount"), TextBox)

If txtMiles.Text <> "" Then

amount = Decimal.Parse(txtMiles.Text) * 0.485
txtAmount.Text = amount.ToString("###.#")
End If

Me.odsAuthExpense.UpdateParameters("amount").DefaultValue = amount
End Sub

Post Your Reply Post New Question

 Viewer's Reply
Could you tell us more precisely..
Answered By Moderator1 on 10/15/2007 6:02:59 AM
Hi,

Thanks for posting your question in our website. We could understand your problem.

when the txtMiles.Text is empty you to convert it as zero. then only it will calculate. else the application will treat it as an empty field and according to your code it will not callculate.

Thanks.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
The Art & Science of JavaScript - Free 100 Page Preview!
No Nonsense XML Web Development With PHP - Free 146 Page Preview!
Sexy Web Design - Free 71 Page Preview!