Getting textbox value when all rows in edit mode

Hi There,

I'm currently writing a small shopping cart for a site of mine. All rows are in edit mode so that a user can enter the qty's he/she desires and the click submit.
I have an autopostback on the text box so that every time a value is changed, I return to the server to recalc the totals.
The datagrid is defined as below (the text box in question is QUANTITY) :

<form runat="Server">
<p>
<asp:DataGrid id="BuyNowGrid" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center">
<FooterStyle borderstyle="None"></FooterStyle>
<Columns>
<asp:BoundColumn HeaderText="BoxImage"></asp:BoundColumn>
<asp:BoundColumn DataField="Description" ReadOnly="True" HeaderText="Description">
<HeaderStyle width="300px"></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Quantity">
<HeaderStyle horizontalalign="Center" width="50px"></HeaderStyle>
<ItemTemplate>
<asp:TextBox id="Quantity" OnTextChanged="Quantity_TextChanged" AutoPostBack="True" runat="server" Width= "50px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Price" ReadOnly="True" HeaderText="Price" DataFormatString="${0:0.00}">
<HeaderStyle horizontalalign="Right" width="70px"></HeaderStyle>
<ItemStyle horizontalalign="Right"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Total" HeaderText="Total" DataFormatString="${0:0.00}">
<HeaderStyle horizontalalign="Right" width="70px"></HeaderStyle>
<ItemStyle horizontalalign="Right"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</p>
</form>


Now, I've made a little test thus :

Sub Quantity_TextChanged(sender As Object, e As EventArgs)
Dim itm As DataGridItem
For each itm IN BuyNowGrid.Items
response.write ("[")
response.write (itm.cells(1).Text)
response.write ("] [")
response.write (itm.cells(2).Text)
response.write ("]<br>")
Next
End Sub

I know the cols start at zero, I've just not bothered column 0 for the test as its emtpy anyway. I get three lines printed out (one for each DB entry). Cell 1 - Description is shown, but not the value out of cell 2.
Any help would be appreciated.
Thanks
PsychoB
0
PsychoBunny
9/17/2003 4:56:16 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
672 Views

Similar Articles

[PageSpeed] 32

Hiya Again.

Well after a day of faffing around trying out various ideas, I've managed to crack it myself. So for anyone else who hits this problem, please see the code below (in relation to my previous post.

Sub Quantity_TextChanged(sender As Object, e As EventArgs)
Dim itm As DataGridItem
Dim tb As TextBox
For each itm IN BuyNowGrid.Items
response.write ("[")
response.write (itm.cells(1).Text)
response.write ("] [")
tb = Itm.FindControl("Quantity")
response.write (tb.text)
response.write ("]<br>")
Next
End Sub

I feel kinda good now ;-).
Regards
PsychoB
0
PsychoBunny
9/18/2003 9:12:12 AM
hi,

Appreciate if you could shed some lights :
Me as well trying to desgin a Shopping Cart. Have some logical problem on designing. I'm not sure where to store the items that user selected to 'Cart'
Shall we store the Item which user selected into a "Cart" in the physcial table !. Or shall we keep in "DataTable" of the dataset.
How did u manged to do this. Aprpeciate if you could share some sample code.
Rgds-

AJ
0
ahmed
9/27/2003 9:59:26 AM
Hi There,

My 'shopping cart' does not use the ADD TO CART scenario. When someone clicks on buy now, I go to a list with all the products (max of 6) and put a qty of 1 in the product where the BUY NOW came from.
The user may then change this, and put qty's in the other products if he/she wishes to buy more than one thing.
For me it's easy as there will only ever be a small number of products.
However, all that being said, the 'standard' way of doing things is to store what the customer has ordered in client side cookies.
Regards
PsychoB
0
PsychoBunny
9/29/2003 9:06:45 AM
Thanks for your reply..

I have an idea, pls advise if it's good logic.
Whatever user added to "cart", I would like to maintain those details (i.e ProdID and Qty) in a session Array(). Upon the confrimatin of Order by user, his/her order will be transfered from Session Array() to databse tabele.
Is it good logic !!!. Pls advise..
Rgds
AJ
0
ahmed
9/29/2003 9:56:22 AM
Reply:

Similar Artilces:

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Unable to get control values from Datalist in edit mode
HiI'm using a generic collection as a datasource for a datalist. The collection object is a class used to contain a string and a few bools. The code I'm using is taken from the ASP.NET Visual Web Developer Helpfile page titled "Allow users to edit items in datalist webserver controls".In the update method I'm extracting the user entered values from the editItemTemplate as follows:    string s = ((TextBox)e.item.findcontrol("username")).Text; But no matter what I do or what I enter into the username control of the datalist the above bit of c...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

How to get the value from a textbox of a datagrid template column while in edit mode using client javascript
Hi, I have added a template column to my datagrid, and in EditItemTemplate tags i am displaying an asp textbox <EditItemTemplate> <asp:TEXTBOX id=TextBox1 Text='<%# Container.DataItem("MyDataField) %>' Runat="server"></asp:TEXTBOX> </EditItemTemplate> i need to get the value of the textbox using a client side scripting language like Javascript. i tried the document.forms[0].TextBox1.value option but does not work I need a solution for this Waiting for replies. i'm trying to figure out the same thing, my current m...

Getting value from a textbox control that was filled with a value from javascript
 I have a textbox control (seen below txtMileageDollars1) that gets filled with javascript based on the number of miles a user types into another textbox (txtMileageMiles1) control.  When I post back with the submit button, the value is blank.  I've tried setting EnableViewState to false, but still cannot get a value on postback.  Does anyone have a solution?   Miles<asp:TextBox ID="txtMileageMiles1" runat="server" Width="50px"></asp:TextBox>   Total (txtMileageMiles1 * rate with javascript)<asp:TextBox...

How to get the Value from the Textbox ?Textbox is created by using add control function.
  Dim textWG As New HtmlInputText textWG.text="Wage Rate" textWG.ID = "txtWG" me.control.add(textWG) i write this code at form load.moreover this form have one save button to save the value from the "txtWG" to database this textbox will be appear when form finish load.but after click save button the value cant be save into database. tat textbox become empty when user click the save button. how can i get the value from that textbox ? Please advice me.Thank you You are using a HTML control and by default, HTML controls dont have a mechanism to pres...

Getting data from controls in Edit mode, I'm confused about control access
I have datagrid with a few BoundColumns, and one TemplateColumn.In edit mode, while trying to save the new record (clicking on "Save")I want to get the new values, I figure out that for BoundColumn I need to get it by : ((TextBox)e.Item.Cells[0].Controls[0]).Text And for TemplateColum I need to do : (TextBox)e.Item.Cells[5].Controls[1]).Text Means, for boundcolumn I'm accessing the first control,and for templatecolumn, the second one.   am I right ? If so, why is that ?   Thanks !...

GridView Datatable source, row editing textboxes always show first row values
Hello,I have my gridview with datasource datatable.  Protected Sub MHistory_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridViewMHistory.RowEditing GridViewMHistory.EditIndex = e.NewEditIndex LoadMHistory(Session("SelectedInventoryNumber")) 'Each row is checked if in edit modus during hte RowDataBound event. End Sub  Public Sub LoadMHistory(ByVal SessionCode As String) Dim MHistoryDataTable As DataTable = New DataTable() MHistoryDataTable = DataAccessLayer...

How to get edited value of the textboxes???
Hi, I am having 4 textboxes with field name,address,phone,email .... OnLoad they get filled with database values....and all fields are in inactive state...as user click the edit button,  all textboxes get active and user can edit the values in it.....Now after editing values, as user click UPDATE button, All edited values should get updated in the database....My update query working fine...But the Problem is that Update query not getting edited value.....getting only the value filled during the load time..... Please help me ...How can i get the edited value in the update query......

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

getting values from controls in gridview rows
hi there, i am building a simple shopping cart, i have a gridview with the products in.  there is a bound field with the product id, a template field (with a table and a load of labels which are bound to the product details via an sql data source and gridviewrowdatabound) and a buttonfield which is the add to cart button. i am calling the rowcommand with the button field and need to get the product id from the boundfield and the quantity from a text box in the template field and write them to my data grid. this is the start of my code behind, the row index works perfectly, ...

Getting data from a textbox in Edit mode...
I have a gridview that is throwing an error when i try to retrieve a value in a textbox in edit mode.  The error is...Could not find control '#ZipCodeEdit.txtZipCode' in ControlParameter 'Zip'.The Gridview looks like: <asp:gridview ID="ZipCodeEdit" AutoGenerateEditButton=True runat="Server" AutoGenerateColumns="false" CellPadding="3" > <Columns> <asp:TemplateField HeaderText="Zip">  <Itemtemplate>   <asp:HyperLink ID="lnkZip" Runat="server&q...

Getting value for dropdownlist in Edit mode.
I've seen a lot of posts for this, but I haven't found one that solves my problem. I have a drop down list in my edit template that the selected value needs to be equal to what's in the textbox in my item template. No matter what I try I get "System.NullReferenceException: Object reference not set to an instance of an object." Here is my datagrid: <asp:DataGrid id="dgOrderDtl" runat="server" CellPadding="3" CellSpacing="0" DataKeyField="DetailID" GridLines="Both" ...

Get the value of any rows into a DetailsView control:
Hi all, I would like to catch the value of a row for a specific row of a detailsview control. I am using a command field which is raised with the OnItemCommand="ChangeRole_Click" property of my DetailsView. I am trying to reach the content of this detailsview by doing somthing like this: void ChangeRole_Click(object sender, DetailsViewCommandEventArgs e) { string recupRole = ((DetailsView)sender).Rows[0].ToString(); Response.Write(recupRole); } But it doesn't work :( Someone could help ? Thanks in advance Benjamin I ha...

Web resources about - Getting textbox value when all rows in edit mode - asp.net.presentation-controls

Google Drive for iOS updated w/ 3D Touch support, Slide Over & Split View multitasking
Google today has updated its Drive app on iOS with a handful of notable new features and enhancements. First off, today’s update to Drive, which ...

Star Wars Bits: Jimmy Kimmel Interviews, Star Wars VR, Starkiller Base Blueprints
It was I who allowed the Alliance to know the location of the Star Wars Bits . It is quite safe from your pitiful little band. This edition of ...

Turkey shooting down that Russian plane doesn't mean war. Yet.
As Turkey shot down a Russian Su-24 military plane at the Turkish-Syrian border on Tuesday morning, the world is once again gearing up for real-time ...

NASA plans twin sounding rocket launches over Norway this winter
This winter, two sounding rockets will launch through the aurora borealis over Norway to study how particles move in a region near the North ...

Yet Another Dell Root Certificate Found Out
It looks like things are not all that rosy over at Dell, as yet another Dell root certificate has been discovered, which is in addition to what ...


Leaked recording: pollution lobbyists discuss exploiting Syrian refugee crisis
A leaked recording made of a conference call posted by the Edison Electric Institute, which lobbies for the power industry, reveals lobbyists ...

Amazon Video gets a bunch of new features on iOS
Amazon has released a ton of new features for its Video app. The update includes 3D touch support, Next Up (which is basically auto-play), picture-in-picture ...

Amazon to Remove Man in the High Castle Nazi Symbols From NYC Subway Cars
Following a copious amount of backlash, Amazon Studios has decided to kill their NYC subway ad campaign by removing the Nazi imagery they put ...

Richard Dawkins Compares Ahmed Mohamed To ISIS Child Soldier
Richard Dawkins is backpedaling after he posted a tweet Tuesday that compared "clock kid" Ahmed Mohamed to an Islamic State child soldier who ...

Resources last updated: 11/24/2015 11:32:51 PM