473,385 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Retrieving the new updated value of a Textbox in a ListView when Update linkbutton is

5
I am unable to get the updated value of textbox within a listview when "Update" link button is clicked which calls a function.
Expand|Select|Wrap|Line Numbers
  1. <asp:ListView ID="_lvCartItems" OnItemUpdating="CartPartItem_OnItemUpdating"
  2.          OnItemDeleting="CartPartItem_OnItemDeleting" runat="server">
  3.  
  4.             <LayoutTemplate>
  5.                 <table width="900px" border="0" style="font-size: small">
  6.                     <tr style="background: #DDDDDD;">
  7.                         <th align="center" style="width:80px">Delete</th>
  8.                         <th align="center" style="width:100px">Quantity</th>
  9.                         <th align="center" valign="top">Part No. </th>
  10.                         <th align="center" valign="top">Part Name </th>
  11.                         <th align="center" valign="top">Total Price</th>
  12.                     </tr>
  13.                     <tr runat="server" id="itemPlaceholder"></tr>
  14.                 </table>                    
  15.             </LayoutTemplate>
  16.             <ItemTemplate>
  17.                 <tr>
  18.                     <td align="center" style="width:80px">
  19.                         <asp:LinkButton runat="server" ID="_lnbDelete" Text="Delete" CommandName="Delete" Font-Underline="True" ForeColor="Black" />
  20.                     </td>
  21.                     <td align="center" style="width:100px">
  22.                         <asp:TextBox ID="_tbQuantity" Text='<%# Eval("quantity") %>' runat="server" MaxLength="2" Width="40px" />
  23.                         <asp:LinkButton ID="_btnUpdateQty" runat="server" CommandName="Update" Text="Update" Font-Underline="True" ForeColor="Black"/>                            
  24.                     </td>
  25.                     <td align="center" style="width:150px">
  26.                         <asp:Label ID="_lblPartNo" Text='<%# Eval("partItem.PartNo").ToString() %>' runat="server"/>
  27.                     </td>
  28.                     <td align="center" style="width:450px">
  29.                         <asp:Label ID="_lblPartName" Text='<%# Eval("partItem.PartName").ToString() %>' runat="server"/>
  30.                     </td>
  31.                     <td align="center" style="width:120px">
  32.                         <asp:Label ID="_lblTotalCost" Text='<%# "$" + Eval("totalCost").ToString() %>' runat="server"/>
  33.                     </td>
  34.                 </tr>                
  35.             </ItemTemplate>
  36.     </asp:ListView>
  37.  
linkbutton update event method

Expand|Select|Wrap|Line Numbers
  1.   protected void CartPartItem_OnItemUpdating(object sender, ListViewUpdateEventArgs e)
  2. {
  3.     //Remeber to handle value of 0 quantity
  4.     Label _lblPartNo = (Label)_lvCartItems.Items[e.ItemIndex].FindControl("_lblPartNo");
  5.     Part p = PartDataLoader.GetPartByPartNo(_lblPartNo.Text);
  6.     cartList = (List<CartItem>)Session["partsInCart"];
  7.     TextBox _tbQuantity = (TextBox)_lvCartItems.Items[e.ItemIndex].FindControl("_tbQuantity");
  8.  
  9.     int qty = Convert.ToInt32(_tbQuantity.Text.Trim().ToString());
  10.  
  11.     if (int.TryParse(_tbQuantity.Text.Trim().ToString(), out qty))
  12.     {
  13.         cartList[e.ItemIndex].quantity = qty;
  14.     }
  15.     else 
  16.     {
  17.         _lblMessage.Text = "Quantity has not been updated.";
  18.     }        
  19.  
  20.     Session["partsInCart"] = cartList;
  21.     _lvCartItems.DataSource = cartList;
  22.     _lvCartItems.DataBind();
  23.     ConvertToPrice();
  24.  
  25.  
I am having a problem retrieving the new value from text box. Pleas advise
Jul 31 '10 #1
2 5043
Frinavale
9,735 Expert Mod 8TB
You are probably overwriting the value in the Page Load event.

Could you please paste the code for your Page Load event?


-Frinny
Aug 2 '10 #2
slao
5
Yes, it was the Page_Load method that was overwriting the textbox value. Got it working. Thanks for your help.
Aug 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: asd | last post by:
I need to find the value/index of the previously selected item of a select list. That is, when the user selects an item from the list and a certain condition elsewhere in the form is not met, I...
6
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been...
2
by: viletter | last post by:
Hi I want to edit dataset - everything is fine, except I can not get updated value using (Textbox)e.Item.Cells.Controls.Text. It is always the value before input. What could be wrong? Thanks in...
0
by: booksnore | last post by:
Help, I have a DataGrid with the Edit, Update and Cancel Columns selected to provide edit by TextBoxs of fields in a table in SQL Server. When I select Edit the Update and Cancel options appear -...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
1
by: active | last post by:
I've been working on a problem for a few days now. I do not get a Double-Click event fired for a ListView when I double click. I now find that if I double click with the right button it works OK....
5
by: cdtsly | last post by:
Hi i have a table with all value at 4 i select all lines in a fetch i update one with a value of 7 i update all the row in the fetch with a value 5 the result is that all my row are at 5 and...
15
by: gunnar.sigurjonsson | last post by:
I´m having some problem retrieving identity value from my newly inserted row into a view. I have two tables T1 and T2 which I define as following CREATE TABLE T1 ( id BIGINT GENERATED ALWAYS...
3
by: mahalaxmi | last post by:
hi, i would like to know how to get the updated value from a master page so that i can update my content page. Description: i have a menu bar in master page and a dropdown control in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.