Problem getting TextBox Value in DataList.

hai guyz,

i'm having a problem getting value from TextBox in the DataList Control. My situation is, i got one "Add to Cart" button,when user press the button it will trigger the Code below (catalog.aspx.cs ).It found the textbox control but can't get the value that i entered.Any idea guyz?.

catalog.aspx
<form id="Form1" method="post" runat="server"> 
<asp:datalist id="DataList1"
runat="server" 
GridLines="Horizontal"
RepeatColumns="1" OnUpdateCommand="DataList1_Update">
      <ItemTemplate>
	<asp:LinkButton CommandName="Update" Runat="server" ID="lnkAddtoCart">Add to Cart</asp:LinkButton>
	<asp:TextBox ID="txtQty" BorderStyle="Groove" Width="32px" Runat="server"></asp:TextBox>
     </ItemTemplate>
</asp:datalist>
</form>
 catalog.aspx.cs 
public void DataList1_Update(object sender,DataListCommandEventArgs e)
		{

			TextBox Qty=new TextBox();
			Qty=((TextBox)e.Item.FindControl("txtQty"));
			if (Qty.Text=="")
			{
				Response.Write("Err:TextBox is Empty");
			}
			else
			{
				Response.Write(txtQty.Text);
			}
		
			
		}
 
 
 

 

0
jonbennet
4/18/2007 7:11:04 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
2679 Views

Similar Articles

[PageSpeed] 38

There is no problem in your code the issue i hope is,  you are rebinding the data on postback. Check in page load whether you rebind the data. If the data is populated on pageload load by checking the ispostback property .

Hope this will help you


Ashok Raja
www.iGold.in

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
1
AshokRaja
4/18/2007 11:14:42 AM
thanx man.it's working
0
jonbennet
4/19/2007 4:18:17 AM

thanks sir, i have solved this problem after reading your ans.

Sunil

0
prajapatiSunil
10/15/2007 6:28:14 AM
Reply:

Similar Artilces:

problem using datalist / how to get value of a control from datalist
Hi all I have a datalist where i m having one linkbutton(where i display name of product ) when i retrive data in datalist on page load there are many rows in datalist.... what i wnat is i want details of the product in OTHER.ASPX on click of linkbutton which is in datalist  can anyone pls help me out....???     Vimal insstead of using link button and use link that will open a new window with Other.aspx and passing a query string like this <a href="other.aspx?productId=<%Container.DataItem("[ur product id fieldname in db]") %>YasserSpica.www...

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....

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...

Problem getting input value from a textbox in a Gridview Control
I placed a text box in one of my template columns in a gridview control:<Columns>                <asp:CommandField ShowEditButton="True" />                <asp:TemplateField><ItemTemplate><asp:TextBox runat=server ID="TextBox" Width="30"></asp:TextBox></ItemTemplate></asp:TemplateField> </Columns>Upon opening a page, my gridview is set up to be populate...

Problem getting an input value from a textbox in a GridView control
I placed a text box in one of my template columns in a gridview control:<Columns>                <asp:CommandField ShowEditButton="True" />                <asp:TemplateField><ItemTemplate><asp:TextBox runat=server ID="TextBox" Width="30"></asp:TextBox></ItemTemplate></asp:TemplateField> </Columns>Upon opening a page, my gridview is set up to be populate...

How do I get get values of controls inside datalist?
How do I get values of controls inside datalist?   For example, if I have a label inside header template or item template or footer template? Is there anyway to change property of label or any other controls inside those template as well? I would really appreciate if anybody can just post a sample code or a helpful link about datalist? Would really like to know more about the events fired for datalist, itembound, itemcreating etc?   hey there,I used this page to work out how to use datalists http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af...

I Used Repeater inside the Datalist now i want to get value of Repeater (textbox control)
I Used Repeater inside the Datalist now i want to get value of Repeater (textbox control) on button click. Button is inside the datalist, Outside repeater.  Depending on datalist "groupId" Repeater is loding and from the repeater i want the value of "Textqty". This is my code <asp:DataList ID="DataList1" runat="server" class="SubContentSearch" DataSourceID="ObjectDataSource1" Width="496px" DataKeyField="id"><ItemTemplate> <asp:Label ID="groupIdLabel" runat="server" Te...

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...

Set TextBox text value to value from DataList Control
I'm sure this is a totally sad question to ask, but... I am using a DataList View to display data. I have a separate form within a LoginView that I would like to use to update a few main fields. I want to set the Text property of the TextBox in my custom edit form to the value of the corresponding field in the DataList. Is this possible? I think i get your question --> you want the text from a  textbox from the datalist to be input into a textbox within your form? try:TextBox tb = DataList1.FindControl("TextBoxIDToFind"); TextBoxOnForm.Text = tb.Text;David Ki...

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...

how ontextchanged event in datalist fire and when that textbox value change than another textbox inside datalist value also change
 i have one datalist into which i used maskededit extender for time entry there is three textbox (1) start_time (2) end_time (3) duration so when enter  end_date value than this text box ontextchage event fire and duration will automatically calculate by(end_time - start_time) and display into datalist duration textbox. in datalist there is more than one item.i put some code so just check  <asp:DataList ID="CONTRACT_SERVICE_ITEM" runat="Server" RepeatColumns="1" RepeatDirection="Horizontal"      &nbs...

Getting the Value from a textbox in Datalist
Hello Everyone, I am hoping that someone could help me. I am using a dropdownlist to load information from an Access Database into the EditItemTemplate of a datalist. All that works fine but I have a problem that I can not seem to get around. I need to grab all the information from the text boxes and one label and one checkbox as the form is being input. Here is the flow that I would like to follow to accomplish what I want.The user opens the web page and the datalist is loadedThe user changes information in each of the textboxesThen the user uses the dropdownlist to change to another r...

How to get value from all controls in datalist?
I want to get the values from all controls in a datalist but I can't find the correct syntax for this. I have this code:         Dim i As Integer        Dim _item As DataListItem         'Loop through datalist        For i = 0 To DataList1.Items.Count - 1            _item = DataList1.Items(i)            Dim lbl As Label = _item.FindControl...

problem with getting textbox value
when i pressed button add, the following code would add a text box to datagridTextBox txtEdit = new TextBox();dgTest.Items[0].Cells[0].Controls.Add( txtEdit ); After that i pressed button delete, the following would remove the textbox from datagridTextBox txtEdit = ( TextBox ) dgTest.Items[0].Cells[0].FindControl("txtEdit");// lblTest.Text = txtEdit.TextdgTest.Items[0].Cells[0].Controls.Remove( txtEdit );What i can not understand is that it removed the textbox sucessfully that means it could find the textbox but it can't not get the text that i typed in the textboxThanks TextBox txt...

Web resources about - Problem getting TextBox Value in DataList. - asp.net.presentation-controls

Email Domain Datalist Helper
What if someone signs up for your web app and they type in their email address as susan_smith@gmaoil.com? They don't notice, they never get their ...

South-west Marine Reserves Network - Resources
[toc on_off::hide=0 on_off::automatic=0 on_off::min_limit=5 box::title=Contents box::minlevel=2 box::maxlevel=2 box::hide_show=1 box::collapsed=1 ...

HTML5无障碍支持解决方案
工作正在进行中:实例解决方案 返回 表的图例 & 说明: “不支持" - 意味着如果提供有建设性意义的变通方案仍不能被浏览器支持。 “部分支持” - 意味着建设性意义的变通方案在浏览器中提供一些无障碍支持。 “没实现” - 意味着新特性在浏览器中仍然没有实现。 “支持” - means ...

銆婄函鐪熺殑骞翠唬銆嬬1闆哶楂樻竻鍦ㄧ嚎瑙傜湅_鏂版氮澶х墖_鏂版氮缃?/title>
... 鏂扮櫧鍙戦瓟濂充紶 鏄庢湞澶╁惎鍥涘勾锛屽箍鍏冨湴鍖鸿繛骞撮ゥ鑽?.. 娓╁窞涓€瀹朵汉 銆婃俯宸炰竴瀹朵汉銆嬩互涓€鎴锋櫘閫氫汉瀹剁殑... 闃垮浣块亾浼?/a> 銆婇樋濞樹娇閬撲紶銆嬩互鏈濋矞鏃朵唬涓鸿儗鏅?.. 鐑棬瑙嗛 姝e湪鍔犺浇...璇风◢绛墌 ${++dataList_index} ...

Adactio: Journal
The thoughts and ramblings of Jeremy Keith, a web developer living in Brighton in southern England.

datalist experiment
demo implementation of datalist element

Issues for pfeldman - Code Review
Keyboard Shortcuts File u : up to issue m : publish + mail comments M : edit review message j / k : jump to file after / before current file ...

Google’s new Chrome Beta 24 is 26% faster than last year’s browser
... the Octane Javascript benchmark. For developers, there are tons of new features in Chrome Beta 24 including new un-prefixed APIs, MathML, datalist ...

Accessible Mozilla: Firefox 24
Alex's blog Wednesday, July 10, 2013 Here's a list of Firefox 24 (currently Aurora ) improvements for assistive technology. ARIA We supported ...

Google Chrome 24 Released, Claims 26% Speed Improvement
Google today released a new version of its browser. On the Octane benchmark, this version is claimed to have 26% speed improvement over the last ...

Resources last updated: 1/8/2016 1:13:57 PM