ok, im trying to make a web app using asp.net and vb, what im doing is i have a mysqldatareader reading the database and writing links to the page, what i want to do is when the link is clicked, i want it to grab the data that is associated with the links row in the database and post it on a new page, here is my code, any help would be tremendous -
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-
<html xmlns="http://www.w3.org/1999/xhtml" >
-
<head runat="server">
-
<title>Untitled Page</title>
-
</head>
-
<body>
-
<a href = "courseinput.aspx">Input</a>
-
<%
-
-
%>
-
-
<form id="form1" runat="server">
-
<div>
-
Current Courses as of
-
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
-
<br />
-
</div>
-
<% Dim connection As New MySql.Data.MySqlClient.MySqlConnection("Data Source=localhost;Database=sigma;User ID=root;Password=root") 'Provide the connection string to your database
-
Dim cmd As MySql.Data.MySqlClient.MySqlCommand
-
cmd = New MySql.Data.MySqlClient.MySqlCommand
-
cmd.CommandText = "select course from course;"
-
connection.Open()
-
cmd.Connection = connection
-
Dim reader As MySql.Data.MySqlClient.MySqlDataReader = cmd.ExecuteReader
-
%>
-
'this is where the links are posted to the page by the reader
-
<% While reader.Read%>
-
<ul>
-
<li><a href = "#"><%Response.Write(reader(0))%></a></li>
-
</ul>
-
<%End While%>
-
-
</form>
-
</body>
-
</html>
-
11 1149
How do you want to post the data to your new page? If you had a class you could call it from both pages.
ok, im trying to make a web app using asp.net and vb, what im doing is i have a mysqldatareader reading the database and writing links to the page, what i want to do is when the link is clicked, i want it to grab the data that is associated with the links row in the database and post it on a new page, here is my code, any help would be tremendous -
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-
<html xmlns="http://www.w3.org/1999/xhtml" >
-
<head runat="server">
-
<title>Untitled Page</title>
-
</head>
-
<body>
-
<a href = "courseinput.aspx">Input</a>
-
<%
-
-
%>
-
-
<form id="form1" runat="server">
-
<div>
-
Current Courses as of
-
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
-
<br />
-
</div>
-
<% Dim connection As New MySql.Data.MySqlClient.MySqlConnection("Data Source=localhost;Database=sigma;User ID=root;Password=root") 'Provide the connection string to your database
-
Dim cmd As MySql.Data.MySqlClient.MySqlCommand
-
cmd = New MySql.Data.MySqlClient.MySqlCommand
-
cmd.CommandText = "select course from course;"
-
connection.Open()
-
cmd.Connection = connection
-
Dim reader As MySql.Data.MySqlClient.MySqlDataReader = cmd.ExecuteReader
-
%>
-
'this is where the links are posted to the page by the reader
-
<% While reader.Read%>
-
<ul>
-
<li><a href = "#"><%Response.Write(reader(0))%></a></li>
-
</ul>
-
<%End While%>
-
-
</form>
-
</body>
-
</html>
-
i would like to post it using the datareader and let the reader read everything to the new page, something like when the user clicks on the link it will search the db for the row associated with that string of text and post it to another page called post where there would be labels to fill in for each part found in the db
basically, i am wanting to know what link is clicked by the user so i can get the link text, search the db, and post to a new page with the information, sorry if im not being clear enough, ive been trying to do postback but cant really find anything that deals with links...
so the events would be
link is clicked
link text is stored in a string
connect to db
search for row associated with string
send to new page called post.aspx
return the results from the db for the link
...when the link is clicked, i want it to grab the data that is associated with the links row in the database and post it on a new page, here is my code, any help would be tremendous
Why not let the other page do the reading? Use a querystring/session object to pass the key information to the next page and let that page do the actual selecting. No need to pass large amounts of data from page to page.
ok, i just looked around on that, but how would handle this when the reader is creating the link for me?
while reader.read
<a href = "post.aspx" lname = "<% response.write(reader(0)) %>
end while
i have the reader creating the link for me from each row in the db so that means that essentailly every link would be same right?, so how would i handle this event? or will the page know what linked was click so that when i call for the querystring, it will have the clicked links text
ok, i just looked around on that, but how would handle this when the reader is creating the link for me?
while reader.read
<a href = "post.aspx" lname = "<% response.write(reader(0)) %>
end while
i have the reader creating the link for me from each row in the db so that means that essentailly every link would be same right?, so how would i handle this event? or will the page know what linked was click so that when i call for the querystring, it will have the clicked links text
Can't you set the value of that reader to a variable, and then use the variable to build your link and link text? I'm not too familiar with the way you are doing things, this looks more like classic ASP.
yeah im just now learning asp.net, ive been doing vb for about 8 months, what methods would i use to do this in asp.net? basically what should i google because ive been looking around, i just dont know really what to look for, about the only thing that i have seen is postback stuff but that sounds like a lot to do for my webapp...
thanks for the quick replies...
yeah im just now learning asp.net, ive been doing vb for about 8 months, what methods would i use to do this in asp.net? basically what should i google because ive been looking around, i just dont know really what to look for, about the only thing that i have seen is postback stuff but that sounds like a lot to do for my webapp...
thanks for the quick replies...
Look up SqlDataSource, and Repeater, for starters. These are really useful for what you need. That would likely be how I would do it. Just set up your sql statement to select the key column (like an id or something) and then the other data you want. Then use the repeater to make a repeating list of links. Use the key data for the link itself, like:
post.aspx?id=value
And use the other info for the link text.
Here's some sample code from one of my applications that uses the SqlDataSource and Repeater controls: -
<asp:SqlDataSource ID="sd1" runat="server" ConnectionString="<%$ ConnectionStrings:AccessConnectionString %>"
-
SelectCommand="SELECT [idDepartment], [dept] FROM [departments]"></asp:SqlDataSource>
-
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="sd1">
-
<ItemTemplate>
-
<a href="test.aspx?id=<%# Eval("iddepartment") %>">
-
<%# Eval("dept") %>
-
</a>
-
<br />
-
</ItemTemplate>
-
</asp:Repeater>
-
What you would want to do is go into Design mode, and then drag a SqlDataSource onto the page. Then configure it, and then drag a repeater onto the page. Set the repeater's datasource to the id of the SqlDataSource you just used. Then use the <%# Eval("value") %> (replace value with the column name) to return the value for that row.
Just google for them to get more familiar with it.
so will this help me with the links? like if i display just the title of the course on the page and when they click on the title link, it gets the rows associated with that clicked link and displays the info on another page?
so will this help me with the links? like if i display just the title of the course on the page and when they click on the title link, it gets the rows associated with that clicked link and displays the info on another page?
Are you trying to list courses on one page, and then display information about the selected course on another? If so, then yes, this can do that. Basically all this is doing is generating links for you. On your next page, you have to handle that. You can get to the value stored in the querystring using this: if your link is:
post.aspx?id=123 use
Request.QueryString("id")
That would return 123. Then use a select statement to get all the data you need for that record and populate the controls on the page.
If you learn a little more about these controls and how to use them, you will see how they apply to this situation.
ok thank you so much, i finally understand this (kinda) haha thanks for the help and the quick replies, i love this site
so i have a strange problem now, ive got the repeater to connect to my mysql db and fill in my links, now my problem is when i pass the querystring......when set a labels text property to the querystring, it comes out right, but when i try to include in a sql statement something like
select * from course where course = '" & this is the variable that holds my requested querystring & "' and run it through a data reader and nothing comes out at all, ive tried in both a page_load event and in the source of the page....any ideas?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt |
last post by:
I always see the term "postback" from ASP book, but I am not sure if I fully
understand the meaning. Here's my understanding so far, please correct me if
any mistakes.
Here's a typical html...
|
by: Matthew Louden |
last post by:
I created simple ASP.NET web application to test how AutoPostBack property
in a web control works.
I set AutoPostBack property to be true of a web control. When I run the
application, here's the...
|
by: Gopal Krish |
last post by:
I'm have coded a simple menu (using link buttons as menu items) in a
user control to be reused across many ASPX pages.
In the page_load method I dynamically create the link buttons as
follows
...
|
by: M |
last post by:
It's possible to call a Page PostBack
with a link (<a href='....'>link</a>)?
I would like only to add to the QueryString a parameter
(i.e. PageN=3 ) and then calling a PostBack
Can I do...
|
by: Craig G |
last post by:
i havent a clue about javascript, i found a small snippet for launching a
datetimepicker, ive used the following to successfully open a small dialog
window for a calender. i want to do something...
|
by: Alejandro Penate-Diaz |
last post by:
Hi. I have posted this question three times in this newsgroup as well as
microsoft.public.scripting.jscript and have get no answer yet. Now I dont
know if my question is too stupid or too weird,...
|
by: Brian Henry |
last post by:
I want to put some interactivity on my form in the form of buttons that are
really links, I know i can do a query string in the link to process their
action based on the type of action specified in...
|
by: graphicsxp |
last post by:
Hi,
WebPage Description:
Contains one datagrid with link button column and one gridview with
dropdownlist column.
<asp:LinkButton id="QueryName" runat="server" autopostback="true"...
|
by: shapper |
last post by:
Hello,
I need to create a data object to hold a number of records with 3
columns. A datatable would do.
My problem is this:
1. I will use this as a GridView datasource.
2. I will need to...
|
by: tiago.private |
last post by:
Hi everybody,
Imagine the following scenario:
One System.Web.UI.UserControl (UC1) with 2 drop downs and one button
"Filter"
One Webform with (UC1) and a GridView, basically the UC1 provides...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| | |