473,395 Members | 1,532 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,395 software developers and data experts.

hyperlinks - does an easier way exist?

hello everybody,
i'm posting this problem because i spent a few hours
on reading forums, newsgroups, tutorials and others
but i still dont know how to solve my problem.
It concerns displaying hyperlink in a datagrid.
Hyperlink is stored in an sql database as plain text.
my table in the database consists of 3 columns: id, text, link.
i would like to display this link as hyperlink (click and redirect to
another web place)

i'm trying to do this similarly to displaying an image (it works with
images)...so
i created a hyperlink column called hyperlink
could you tell me what i'm doing wrong? maybe there is an easier way to do
this?

<asp:DataGrid id="DataGrid2" runat="server"
OnItemDataBound="DataGrid2_ItemDataBound">
....
<asp:HyperLinkColumn DataNavigateUrlField="id" HeaderText="hyperlink"
NavigateUrl='sklep2.aspx?id=<%#
Convert.ToString(DataBinder.Eval(Container.DataIte m,"id")) %>'
</asp:HyperLinkColumn>

....
void DataGrid2_ItemCommand(object sender, DataGridCommandEventArgs e) {
System.Web.UI.WebControls.HyperLink linka = new
System.Web.UI.WebControls.HyperLink();
if((e.Item.ItemType == ListItemType.Item)||(e.Item.ItemType ==
ListItemType.AlternatingItem)){
linka.NavigateUrl = "sklep2.aspx?link="+e.Item.Cells[3].Text;
}
}

and

void BindGrid(){
string conStr = "server=\'(local)\'; trusted_connection=true;
database=\'test\'";
SqlConnection Con = new SqlConnection(conStr);
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM squad", Con);
DataSet ds = new DataSet();
da.Fill(ds,"squad");
DataGrid2.DataSource = ds;
DataGrid2.DataBind();
}
file sklep2.aspx :

void Page_Load(object sender,EventArgs e){
string LinkID = Request.QueryString["id"];
string conStr = "server=\'(local)\'; trusted_connection=true;
database=\'test\'";
SqlConnection Con = new SqlConnection(conStr);
SqlCommand Com = new SqlCommand("SELECT * FROM squad WHERE id="+LinkID,
Con);
try{
Con.Open();
SqlDataReader MYDATA;
MYDATA = Com.ExecuteReader(CommandBehavior.CloseConnection) ;
Response.Write("<a
href="+MYDATA["link"].ToString()+">link</a>");
Con.Close();
}
catch(SqlException EXEPT){
Span1.InnerHtml = "READING Failed. DETAILS: "+EXEPT.ToString();
}}

best regards,
p.

Nov 18 '05 #1
0 916

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

Similar topics

3
by: Aasp | last post by:
Hello! I'm a complete Javascript newbie and my question is surely very naive, but believe me, I've spent this whole day searching thru the net and didn't find any solution to my little problem....
6
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would...
1
by: Tom | last post by:
I have a project database in which I use hyperlinks to call up various related supporting documents (e.g., proposals, contracts, reports, site photos, etc.). The documentes are in Word, Excel, PDF...
2
by: laredotornado | last post by:
Hello, I want to take a block of text and add html tags to make hyperlinks where hyperlink strings exist. So, if I have a variable $a = "This is http://www.yahoo.com" I would like to run...
4
by: Seefor | last post by:
Hi, I want my text hyperlinks to have a dotted border underneath, so I did this which works fine: a, a:link, a:visited, a:hover, a:active { color: #000; text-decoration: none;
9
by: Viken Karaguesian | last post by:
Hello all, I'm making a calendar section in a website. Each month is its own page and navigated by Previous / Next links. I have it working now with standard hyperlinks, but I want to learn how...
3
by: prinsipe | last post by:
Hi all, what i'm doing is showing/hiding hyperlinks depending on the hyperlink clicked. it is partially working. when i call step1, all hyperlinks are hidden. but then i call step2, single and...
2
by: Nathan | last post by:
I'm trying to use a LocalReport in a ReportViewer and make a couple fields in the report show up as hyperlinks so I can navigate to other pages after running the report. The hyperlinks themselves...
92
by: Erwin Moller | last post by:
Hi group, I encoutered page validation error, but I don't know a way around. The page has the following doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.