473,804 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please HELP! Need to access textbox control values within a repeater control

Hi There,

I have a shopping cart app that displays products along with a textbox
(to enter quantity) and an image button to add the item to the
shopping cart. Please explain why my below Button_Click procedure
does not retrieve the value of the textbox where the button was
clicked.

Thanks in Advance,

Darren


Sub Button_Click(s as Object, e as ImageClickEvent Args)
Dim Btn As System.Web.UI.W ebControls.Imag eButton = s
Dim iId as integer
iId=Btn.Command Argument
Response.write (iId)
Dim tb as System.Web.UI.W ebControls.Text Box =
btn.Parent.Find Control("txtVal ue")
Response.write ("TextBox Value=" & tb.Text)
End Sub
-------------------------------------------------------
<form id="frmProducts " runat="server">
<asp:repeater id="rptProducts " Runat="server">
<ItemTemplate >

a href="ProductIn fo.aspx?id=<%# DataBinder.Eval (Container.Data Item,
"prodid") %>"><%# DataBinder.Eval (Container.Data Item, "prodname")
%></a></b></td>

<%# DataBinder.Eval (Container.Data Item, "catdesc") %></td>

<%# formatcurrency( DataBinder.Eval (Container.Data Item,
"retailprice"), 2) %>

member price:&nbsp;<b> <%#
formatcurrency( DataBinder.Eval (Container.Data Item, "memberprice"), 2)
%></b></td>
<asp:TextBox runat="server" width="20" name="txtValue" id="txtValue"
CommandArgument =<%# DataBinder.Eval (Container.Data Item, "prodid") %>
/>
<asp:imagebutto n id=btnAddCart CommandArgument =<%#
DataBinder.Eval (Container.Data Item, "prodid") %> BorderWidth="0"
onclick=Button_ Click Runat="server" ImageUrl="Frame/btnAdd.gif"/>

</ItemTemplate>
</asp:repeater>
Nov 18 '05 #1
5 7278

Add OnItemCommand=" Repeater_Select " to the repeater

then in the code
public void Repeater_Select ( object source, RepeaterCommand EventArgs e )

{

}
use the CommandArgument property of the imagebutton to pass thorugh the information you require..

if you need multiple values then do the following
CommandArgument ='<%# DataBinder.Eval (Container,"Dat aItem."+ ITEMONE +","+ ITEMTWO") %>'

then just split on that..
string res = e.CommandArgume nt.ToString();

string delimStr = ",";

char [] delimiter = delimStr.ToChar Array();

string[] vals = res.Split(delim iter);

string s = vals[0].ToString();

string x = vals[1].ToString();

"Darren Smith" <da**********@c a.trader.com> wrote in message news:e0******** *************** **@posting.goog le.com...
Hi There,

I have a shopping cart app that displays products along with a textbox
(to enter quantity) and an image button to add the item to the
shopping cart. Please explain why my below Button_Click procedure
does not retrieve the value of the textbox where the button was
clicked.

Thanks in Advance,

Darren




Sub Button_Click(s as Object, e as ImageClickEvent Args)
Dim Btn As System.Web.UI.W ebControls.Imag eButton = s
Dim iId as integer
iId=Btn.Command Argument
Response.write (iId)
Dim tb as System.Web.UI.W ebControls.Text Box =
btn.Parent.Find Control("txtVal ue")
Response.write ("TextBox Value=" & tb.Text)
End Sub
-------------------------------------------------------
<form id="frmProducts " runat="server">
<asp:repeater id="rptProducts " Runat="server">
<ItemTemplate >

a href="ProductIn fo.aspx?id=<%# DataBinder.Eval (Container.Data Item,
"prodid") %>"><%# DataBinder.Eval (Container.Data Item, "prodname")
%></a></b></td>

<%# DataBinder.Eval (Container.Data Item, "catdesc") %></td>

<%# formatcurrency( DataBinder.Eval (Container.Data Item,
"retailprice"), 2) %>

member price:&nbsp;<b> <%#
formatcurrency( DataBinder.Eval (Container.Data Item, "memberprice"), 2)
%></b></td>


<asp:TextBox runat="server" width="20" name="txtValue" id="txtValue"
CommandArgument =<%# DataBinder.Eval (Container.Data Item, "prodid") %>
/>


<asp:imagebutto n id=btnAddCart CommandArgument =<%#
DataBinder.Eval (Container.Data Item, "prodid") %> BorderWidth="0"
onclick=Button_ Click Runat="server" ImageUrl="Frame/btnAdd.gif"/>

</ItemTemplate>
</asp:repeater>

Nov 18 '05 #2
Hi Darren,

Thanks for your prompt reply, most appreciated.

public void Repeater_Select ( object source, RepeaterCommand EventArgs e )

{

}

Does the Repeater_Select Sub remain empty?

commandargument ='<%# DataBinder.Eval (Container,"Dat aItem."+ ITEMONE
+","+ ITEMTWO") %>'

Is the above commandargument added to the imagebutton?

string res = e.CommandArgume nt.ToString();
string delimStr = ",";
char [] delimiter = delimStr.ToChar Array();
string[] vals = res.Split(delim iter);
string s = vals[0].ToString();
string x = vals[1].ToString();

Is the above code placed in the Repeater_Select or the ImageButton
On_Click routine?

Thanks,

Darren

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

Sorry, one more thing...

At which point does the routine pass the value of the quantity textbox?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
I should have put this in before...
Here is an example..

<asp:Repeater Runat="server" ID="JobPosts" OnItemCommand=" Repeater_Select ">
<p>
<asp:imagebutto n
CommandArgument ='<%# DataBinder.Eval (Container,"Dat aItem."+ JR.Core.Data.Jo bData.FLD_JOB_I D) %>'
CommandName='Ed itJob'
id="EditJob" onmouseover="th is.src ='../Images/editover.gif'"
onmouseout="thi s.src ='../Images/editnorm.gif'" Runat="server"
ImageUrl="../Images/editnorm.gif"
AlternateText=" Edit Job">
</asp:imagebutton >
</p>
</asp:Repeater>
When the imagebutton is clicked it will push the event up to the repeaters onitemcommand
public void Repeater_Select ( object source, RepeaterCommand EventArgs e )
{
///<summary>
/// THis is when a button is selected from inside the repeater.
///</summary>

// Get the JobID and then send the user to the correct page.
string JobID = e.CommandArgume nt.ToString();

Session["JobID"] = e.CommandArgume nt.ToString();

if (e.CommandName. ToString() == "JobResults ")
{
Response.Redire ct("JobResults. aspx");
}
else if(e.CommandNam e.ToString() == "EditJob")
{
Response.Redire ct("EditJob.asp x");
}
else if (e.CommandName. ToString() == "ArchiveJob ")
{
// this is used as the CommandArgument passess 2 values through as s delimtered string eg. val1,val2

string res = e.CommandArgume nt.ToString();
string delimStr = ",";
char [] delimiter = delimStr.ToChar Array();
string[] vals = res.Split(delim iter);
string s = vals[0].ToString();
string x = vals[1].ToString();
int jobID = Convert.ToInt32 (s);
int status = Convert.ToInt32 (x);
JobManager man =new JobManager();
man.UpdateJobSt atus(jobID,stat us);
}
}

"dsmith" <id***@attenua. com> wrote in message news:eZ******** ******@TK2MSFTN GP11.phx.gbl...
Hi Darren,

Thanks for your prompt reply, most appreciated.

public void Repeater_Select ( object source, RepeaterCommand EventArgs e )

{

}

Does the Repeater_Select Sub remain empty?

commandargument ='<%# DataBinder.Eval (Container,"Dat aItem."+ ITEMONE
+","+ ITEMTWO") %>'

Is the above commandargument added to the imagebutton?

string res = e.CommandArgume nt.ToString();
string delimStr = ",";
char [] delimiter = delimStr.ToChar Array();
string[] vals = res.Split(delim iter);
string s = vals[0].ToString();
string x = vals[1].ToString();

Is the above code placed in the Repeater_Select or the ImageButton
On_Click routine?

Thanks,

Darren





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #5
Worked like a charm. Thanks for your assistance.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2016
by: KK | last post by:
Hi Peoples, Can anyone give me any learning materials for learning C++. i.e. can you give me any docs or give me the link to any website that has info on programming in general or C++. (ok I know I could go to a library and read books on C++ but looking for something urgently.)
3
2330
by: Lodewijk van Haringhal | last post by:
I'am new with javascritping not with programming. Is there nobody who can help me with ths simple promblem? :) Please, please give me a hint. Please help me with this script. I have two lists in my form. One to choose a directory and one to choose a picture. The script bellow works perfect without the directory choose function. I tried to make the directory choose function myself but I did not succeed. I think I made a mistake here:...
6
1806
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7" valign="top"><form name="booknow"><select
6
5812
by: raj | last post by:
When I try to sort my combo box I get the following error. "Cannot sort a ComboBox that has a DataSource set. Sort the data using the underlying data model." --------------------------------THe code is given below. String strSQL; strSQL = "SELECT .......... WHERE C.Client = '" + this.cboClient.SelectedValue + "' ";
0
1705
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web browser that Hotmail does not support. If you continue to use your current browser software we cannot guarantee that Hotmail will work correctly for you". Please help, this is very annoying. I have been searching for help on
5
2295
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action to either a) generate numbers b) Prompts a user to locate a web page c) go to previous page in history list d) Loads next page in history list e) Promps the user for a URL and loads the web page in a new window f) and Re-Sizes the window. ...
7
3623
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
1
2294
by: glenn123 | last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre button the list is populated with a list of that genre. I have got the interface done to satisfaction, my problem is that when i press the change genre button nothing happens and when i select a track to play from the list which is setvisible and...
0
970
by: lvishnugoud | last post by:
Hi, Please Help me for solve this problem. Actually i am create ing help (.chm) files by using HelpNavigator enumrator and showhelp method. I am getting result but in help file left panel index i am not getting the content name . so plese tell me how can i get this . My code is private void showhelp(string currentpage)
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.