This is a migrated thread and some comments may be shown as answers.

[Solved] Grid Button link to new page

2 Answers 248 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marta
Top achievements
Rank 1
Marta asked on 24 Apr 2009, 04:03 PM

 

Hi! I am knew to asp.net and telerik. I am using a grid to show a list of contents by linking it to a datasource which executes a select query. I would like to have a button on each line of the grid for each content, which when the user clicks on it, takes him to a new page where he can view the details of that specific content.

I have the following columns:

 
 

<Columns>

<rad:GridBoundColumn DataField="Title" HeaderText="Title" SortExpression="Title" UniqueName="Title">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataFormatString="{0:d}" DataField="PublicationDate" DataType="System.DateTime" HeaderText="Publication Date" SortExpression="PublicationDate" UniqueName="PublicationDate">

</rad:GridBoundColumn>

<rad:GridBoundColumn DataField="Topic" DataType="System.Guid" HeaderText="Topic" SortExpression="Topic" UniqueName="Topic">
 
</rad:GridBoundColumn>
 
<rad:GridButtonColumn Text="View Details" CommandName="ViewDetails">

</rad:GridButtonColumn>

</Columns>
 
and the query that feeds the grid is:

"SELECT [Title], [PublicationDate], [Topic], [AuthorID]

FROM ([NL_LMS_BIB_contents] INNER JOIN NL_LMS_BIB_topics

ON NL_LMS_BIB_contents.TopicID= NL_LMS_BIB_topics.TopicID)

INNER JOIN NL_LMS_BIB_users

ON NL_LMS_BIB_contents.AuthorID= NL_LMS_BIB_users.UserID"

 
Can anyone please help me so that when the user clicks on the button for that content, the ContentID is passed and the user is redirected to a new page with details of that content?

Thanks a lot :)

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Russ
Top achievements
Rank 1
answered on 24 Apr 2009, 04:40 PM
You're probably looking for something like a GridHyperLinkColumn instead of Button Column.   You can pass values along through the hyperlink like this (untested):

<telerik:GridHyperLinkColumn DataNavigateUrlFormatString="/myurl.aspx?title={0}"   
         Target="_self" DataTextFormatString="my edit page"   
         DataNavigateUrlFields="Title" UniqueName="ExternalEditLink">      
</telerik:GridHyperLinkColumn> 

Then, in the linked page's code, get the key value via the QueryString:

      string thisTitle = Request.QueryString[

"title"].ToString();

 



Good Luck,
Russell.
0
Marta
Top achievements
Rank 1
answered on 24 Apr 2009, 05:12 PM
Thanks a lot Russell! That really helped :)
Tags
Grid
Asked by
Marta
Top achievements
Rank 1
Answers by
Russ
Top achievements
Rank 1
Marta
Top achievements
Rank 1
Share this question
or