Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
a question in asp.net

with sql server 2005 i made a table by field(id,title,subject,article) .also i made a page that make records. i want to show titles in the first page and make them link to another page that shows field "article".

but i dont know what i shoud use?repeater or datagrid or...
also i dont know how can i make the titles link to another field "article"
Posted
Updated 25-Aug-12 8:00am
v4
Comments
Kenneth Haugland 25-Aug-12 13:56pm    
DataGrid is usually the normal way. But listview and other controls could be used too, it depends on what you want to do.

Datagrid is the best way i think.make the first column of the datagird as link and from here refers to your record page.It will be easy and less code required.
 
Share this answer
 
Comments
ridoy 25-Aug-12 14:32pm    
<asp:GridView ID="GridView1" CssClass="listStyle" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="courseNo">

<columns>

<asp:HyperLinkField HeaderText="Course No" DataNavigateUrlFields="courseNo" DataNavigateUrlFormatString="~/Editing.aspx?courseNo={0}"
DataTextField="courseNo" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6" />




look at this code..here the first column couseNo contains the course number.but all of them act link as a link..and when you click it,DataNavigateUrlFormatString will refer you to Editing page..
fjdiewornncalwe 27-Aug-12 9:56am    
Good answer. +5.
If you are going to enhance your answer like you have done here, you can use the Improve Solution widget at the right of your answer and then add you edits through that tool. It saves a comment and will allow you to use the pre tags for code where the comment tool does not.
ridoy 27-Aug-12 11:58am    
thanks Marcus..i will look it future..thanks for your suggestion
Consider using meaningful tags.

You can use anything you like, a gridview has more built in and a repeater is more flexible. You make a link by passing an id on the url and making a page that looks up data by the id and displays it
 
Share this answer
 
Use DataGrid/GridView to Display the title and on DataItemBound Event Bind the Row id of the rEcord and then pass it to Article page as a parameter and display the Record based on Article ID from Prev. Page.
 
Share this answer
 
After you get all fields you needed from database , use to title:
C#
<asp:hyperlink id="HyperLink1" runat="server" xmlns:asp="#unknown">article_ field</asp:hyperlink>

and in code page (.aspx.cs)write:
C#
protected void Page_Load(object sender, EventArgs e)
    {

C#
HyperLink1.NavigateUrl = "~/page2.aspx";
}

good luck
 
Share this answer
 
If you want to show the data only then you should use repeater only. it is a light weight tool. for navigation you can use anything like this.
HTML
<a href='<%#"webForm2.aspx?LinkValue=<%# DataBinder.Eval(Container.DataItem,"sal") %>"></a>


Then on the PageLoad of webForm2 you can extract the value using
C#
string MyValue = Request["LinkValue"];

You can use this also:
C#
<asp:hyperlink id="hyp1" runat="server" xmlns:asp="#unknown">
                                    NavigateUrl='<%#Eval("Q_id","~/question_dtl.aspx?LinkValue={0}") %>' 
                                    Text="Details" />


They will give hyperlink for another page
You can use these in item template block.
 
Share this answer
 
v5
This is a small an silly question. You should try using google first. What have to tried yet? Rather Copy/Pasting or doing some coding for you, I would refer this(Check this out[^]).



--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900