Last post Jan 08, 2016 07:48 PM by ObulorN2
Jan 04, 2016 07:48 PM|ObulorN2|LINK
Hi, many thanks in advance.
Here it goes , I have a Gridview that has a Quantity column. and Equally have a Button field with Text property as Increament and CommandName as Increament.
In Edit mode; Quantity column has a textbox, EditQtyTextBox
All i want was to click the Button field and have the value of EditQtyTextBox increament by +1
Here is what I have done in RowCommand event:
if e.commandname ="Increament" then
dim index as integer =convert.ToInt32(e.commandArgument).Tostring
dim Row as GridviewRow =grv.Rows(index)
dim EditQty as Textbox = directcast(Row.findcontrol("EditQtyTextBox"),Textbox)
Dim Increament as Integer =cType(EditQty.Text.Tostring,Integer)
Increament =Increament +1
The Probs is the variables and controls seems to work ok at code end but the textbox at the Gridview(gvr) IS NOT Displaying the increamented value.
Least I forget the Gridview is databond fro database.
Will appreciate any help.
Jan 05, 2016 01:50 AM|oned_gk|LINK
Ensure, if you bind the grid in page_load event, call it in not ispostback block
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Protected Sub grv_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grv.RowCommand
If e.CommandName = "Increament" Then
Dim index As Integer = e.CommandArgument
Dim Row As GridViewRow = grv.Rows(index)
Dim EditQty As TextBox = DirectCast(Row.FindControl("EditQtyTextBox"), TextBox)
Dim Increament As Integer = EditQty.Text
Increament = Increament + 1
EditQty.Text = Increament
Jan 05, 2016 10:19 AM|ObulorN2|LINK
Nope, I did the binding in a private sub this way:
Protected Sub Binding..grv.datasource=Datasourcegrv.databind.. End Sub
Based on your advice I equally tried this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Binding End IfBut yet no luck.I was wondering if it has anything to do with setting focus at the textbox first.
Jan 08, 2016 07:48 PM|ObulorN2|LINK
I got me help from this old thread:
thanks to everyone that stop by.