Alternative Nation
Go Back   Alternative Nation > Lifestyle > Computers & Technology > Web Dev & Programming
Spoilt pig

Notices

Reply
 
Thread Tools Rate Thread
Old 26th April 2009, 3:24pm   #1
HAX0R JIM DUGGAN
 
Joe Spinebuster's Avatar
 
Join Date: Apr 2001
Location: PARTS UNKNOWN
Posts: 13,378
Images: 19
Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'
Send a message via AIM to Joe Spinebuster Send a message via MSN to Joe Spinebuster Send a message via Yahoo to Joe Spinebuster
Question Database And .net Guys, Plz Assist

Alright, so I have a webpage and on that webpage I have a link that looks like this:
Quote:
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="product_page.aspx?Product_ID=1">Displ ay more info on item</asp:HyperLink>
On this page I place a GridView which is linked to display the contents of a database with a list of items.

What I want to do is place the link inside the last column of the GridView, and change it so the value after "Product_ID=" related to the "ProductID" column of my database. Ya dig?

I tried changing the ItemTemplate of the last column of the GridView to this:
Quote:
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="product_page.aspx?Product_ID='<%# Bind("ProductID") %>'">Display more info on item</asp:HyperLink>
BUT, apparently it's not as straightforwards as that. Hopefully this'll show what I'm trying to do, though. If you know what to do, explain clearly coz I am mad fuckin' new at this.

ANYONE...?
__________________


MY BAND'S MYSPACE | MY BRUTE
Quote:
Originally Posted by Joni Mitchell View Post
YOU ARE A FUCKING DICK FREAK!! AND I HOPE YOU DIE TRYING TO SUCK YER DICK!!!!
Joe Spinebuster is offline   Reply With Quote
Old 26th April 2009, 8:01pm   #2
Changed Man V4
 
Join Date: May 2002
Location: Breaking into H
Posts: 32,422
Images: 303
Zooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than Hoody
Send a message via MSN to Zooropa
Re: Database And .net Guys, Plz Assist

Few ways to do this mate:


<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:HyperLink runat="server" ID="hlinkView1" Text='Select' NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.LETTER_ID", "./EditLetter.aspx?LETTER_ID={0}") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

That's one way.

So here the container is the gridview, bound to a datasource.
So in the above example, I'm looking at the Dataitem called "LETTER_ID", that's the field name in the dataset.

So I'm guessing yours might be something like:

<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.ProductID", "./product_page.aspx?Product_ID={0}") %>'




Another way to do it would be to add an event to the gridview "ondatabound".

Then loop through the gridview rows using a "for each", and manually set the HyperLink.NavigateURL property.

Any bother gies a shout.
__________________
You just lost The Game

If animal trapped call 844-6286
Zooropa is offline   Reply With Quote
Old 26th April 2009, 9:44pm   #3
HAX0R JIM DUGGAN
 
Joe Spinebuster's Avatar
 
Join Date: Apr 2001
Location: PARTS UNKNOWN
Posts: 13,378
Images: 19
Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'
Send a message via AIM to Joe Spinebuster Send a message via MSN to Joe Spinebuster Send a message via Yahoo to Joe Spinebuster
Re: Database And .net Guys, Plz Assist

Incredible, thanks a lot Marc. You may come to regret that last line in your post, coz I'm working on something and will no doubt get stumped like a motherfucker at pretty much every turn, but I'll TRY not to be a wideo since it's that wee bit more satisfying to figure things out myself. Although pasting in that HyperLink NavigateUrl magic of yours and seeing it actually work was still immensely satisfying. *KISSEZ U*
__________________


MY BAND'S MYSPACE | MY BRUTE
Quote:
Originally Posted by Joni Mitchell View Post
YOU ARE A FUCKING DICK FREAK!! AND I HOPE YOU DIE TRYING TO SUCK YER DICK!!!!
Joe Spinebuster is offline   Reply With Quote
Old 26th April 2009, 9:52pm   #4
John Ringo
 
Dyno's Avatar
 
Join Date: May 2002
Posts: 14,066
Images: 12
Dyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about repDyno couldn't care less about rep
Send a message via MSN to Dyno
Re: Database And .net Guys, Plz Assist

Lev never Kissez me
Dyno is online now   Reply With Quote
Old 27th April 2009, 1:40pm   #5
HAX0R JIM DUGGAN
 
Joe Spinebuster's Avatar
 
Join Date: Apr 2001
Location: PARTS UNKNOWN
Posts: 13,378
Images: 19
Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'Joe Spinebuster sings 'rep rep repitty-rep'
Send a message via AIM to Joe Spinebuster Send a message via MSN to Joe Spinebuster Send a message via Yahoo to Joe Spinebuster
Re: Database And .net Guys, Plz Assist

Quote:
Originally Posted by Dyno View Post
Lev never Kissez me
Marc gives me assistance with things, and you - in the words of DMX - ain't never gave nothin' ta me! Except a Mars bar shaped void in my sweety collection.
Quote:
Originally Posted by Joe Spinebuster View Post
I'll TRY not to be a wideo
Pure liar, got stuck again already. MY NEW PROBLEM IS THIS:

I have a button click event that stores a number of session variables, like so:
Quote:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Session("No_Item") = Session("No_Item") + 1
Label1.Text = Session("No_Item")
Session("Item_Name") = "Golden Sword"
Label2.Text = Session("Item_Name")
Session("Total_Item") = Session("Total_Item") + 1500
Label3.Text = FormatNumber(Session("Total_Item"), 2)
Session("TOTAL_BASKET") = Session("Total_Item")
BASKET.Text = FormatNumber(Session("TOTAL_BASKET"), 2)
End Sub
THING IS, I want the value of the session variable "Item_Name" to actually be retrieved from a label named "ProductNameLabel" on my page, and I want the value of the session variable "Total_Item" to be Total_Item + a value retrieved from a label named "UnitPriceLabel". I thought I would be able to do this like so:
Quote:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Session("No_Item") = Session("No_Item") + 1
Label1.Text = Session("No_Item")
Session("Item_Name") = CStr(ProductNameLabel.text)
Label2.Text = Session("Item_Name")
Session("Total_Item") = Session("Total_Item") + CInt(UnitPriceLabel.text)
Label3.Text = FormatNumber(Session("Total_Item"), 2)
Session("TOTAL_BASKET") = Session("Total_Item")
BASKET.Text = FormatNumber(Session("TOTAL_BASKET"), 2)
End Sub
But, as usual, my logic does not apply and the bits in bold are throwing up errors because the labels they refer to are in a DataList and the button click event can't see them because of this.

Is there a way to make my button click event read the values of labels inside a DataList, and store them as session variables?
It would also be nice if I could make the session variable name "No_Item" relative to a label - eg it reads a label with the value "1" and makes the session variable name "No_Item_1", reads a label with the value "2" and makes the session variable name "No_Item_2", etc., but I think I may be attempting the impossible with that. Actually, for all I know it could be the easiest thing in the world, I really am horribly new at this.

For anyone trying to read the code and figure out what I'm up to - yes, I AM testing out this stuff by pretending to be a shopkeeper from a Zelda game setting up an online store.
__________________


MY BAND'S MYSPACE | MY BRUTE
Quote:
Originally Posted by Joni Mitchell View Post
YOU ARE A FUCKING DICK FREAK!! AND I HOPE YOU DIE TRYING TO SUCK YER DICK!!!!
Joe Spinebuster is offline   Reply With Quote
Old 27th April 2009, 7:11pm   #6
Changed Man V4
 
Join Date: May 2002
Location: Breaking into H
Posts: 32,422
Images: 303
Zooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than HoodyZooropa is better than Hoody
Send a message via MSN to Zooropa
Re: Database And .net Guys, Plz Assist

Ah, a datalist.

Where does the button sit? Does it sit next to each item on the datalist, or is sitting at the bottom of the page so that you maybe select something in the datalist, and the button at the bottom does something with the selected item?

For controls like textboxes/labels and that sitting inside a container (datalist/grdiview/datagrid/formview) you need to use findcontrol.

So might be something like:

Dim ADDRESS_IDLabel As Label = Me.DataList1.Items(0).FindControl("ADDRESS_IDLabel ")
Dim textADDRESS_IDLabel As String = ADDRESS_IDLabel.Text

You can see I did DataList.Items there.
items are basically the rows that make up the content of the datalist.
The 0 is the index of the datalist, so the first one it finds.

If you get stuck post up a rough idea of what the page should be doing and should be able to help you out.
__________________
You just lost The Game

If animal trapped call 844-6286
Zooropa is offline   Reply With Quote
Reply

Bookmarks
Digg del.icio.us StumbleUpon Google

Tags
.net, asp, database, drink my drink, install linux, smoke my weed

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Dependable UK Web Hosting - Kualo
 









Powered by vBadvanced CMPS v3.0.0
Advertisement
   



All times are GMT +0. The time now is 10:25pm.

Forums Directory
Copyright 2000-2008, Alternative Nation

SEO by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Page generated in 0.55701 seconds with 21 queries