I am (a novice and) trying to make a shopping cart for a bookstore (using vb). The shopping cart page shows a gridview where all the items the customer wants to purchase is listed (the gridveiw has columns for isbn, title, price and amount). The amount column is a text box, where the user can change the amount. Under the grid view I have a button <update amount>. A click on this button is supposed to go through the gridview to see if the user has changed the amount of any of the books. If so, the price is to be changed. If the amount of one book is set to 0 the row is to be deleted from the gridview. Can some one help me with the code needed to accomplish this?
Hi:
You might be trying the RowDataBound event to do what you want to do.
This event is fired for each row that is bound to data. So in this level, you have access to the data inside the row.
You would check if the data in a certain cell is 0, then you simply hide the current row, something as:
protected void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e) {if(e.Row.RowType == DataControlRowType.DataRow) {if (e.Row.Cells[1].Text =="0") { e.Row.Visible =false; } } }
Just an idea, start with it and tell us what happens.
HTH,
Regards
Hi.
Thanks for your answer. I might have posted this question in the wrong forum. I am using Visual Studio 2005. (Can I move my post ??) I did not understand your code and don't think I can use this in visual studio(?). My mistake. Sorry!
in the button click event, you need to write code that does the following...
For each row in t Gridview1
If row.type is not a header or footer then
dim mytextbox as textbox = gridview.row(e.gridview.rowindex).findcontrol("Quantity")
if textbox.changed= true then
UpdateQuantity(cartid,item,newqty)
end if
end if
next row
Sub UpdateQuantity(cartid,item,newqty)
Do Sql / database work here
End sub
i base this psuedo code on the ibuyspy example (asp.net 1.1)
http://www.asp.net/IBS_Store/docs/docs.htm
and from there tohere - checkout the shoppingcart.aspx and the shoppingcartdb stuff
0 comments:
Post a Comment