Make your online existence with me              


 


 

 

Warning: main(menu.php) [function.main]: failed to open stream: No such file or directory in /home/mohamedb/public_html/lesson_gridview_link.php on line 290

Warning: main(menu.php) [function.main]: failed to open stream: No such file or directory in /home/mohamedb/public_html/lesson_gridview_link.php on line 290

Warning: main(menu.php) [function.main]: failed to open stream: No such file or directory in /home/mohamedb/public_html/lesson_gridview_link.php on line 290

Warning: main() [function.include]: Failed opening 'menu.php' for inclusion (include_path='.:/usr/php4/lib/php:/usr/local/php4/lib/php') in /home/mohamedb/public_html/lesson_gridview_link.php on line 290






How to add links to grid view !!

here i am going to explain how to add links to grid view

i have a jobs table that has the following fields

table

in a gridview i need only the job title and date_added fields to be displayed where the job_title will be a link to view all details of the specified job i.e. to get all other fields from the database

so i will start with dragging a gridview control to add it to the page and add new data source

gridview

i will choose the data source to be the jobs table and also check the fields i need to display in the gridview which will be the id,job_title and date_added

select_query

 

i will test the query to see if it's working

test_query

after everything is ok i click on the gridview and select edit columns

edit columns

 

in the edit columns screen i will add HyberLinkedField and edit it's properties as shown in the next figure

 

where the DataNavigateUrlField will be the id to send it as URL parameter to the next page

and the DataNavigateUrlFormatString will be the page where i am redirecting to which will be view_details.aspx?id={0} where 0 is the first column specified in the query which is the id of the job

and the DataTextField will be the job_title field where it will be displayed as a link

and in the HeaderText i will write jobs

then i will remove the job_title from the selected_fields pane as it will be displayed in the hyperlink column so everything will look like the following

final

then i view the page in the browser

 

next i am going to create the view_details.aspx page where it will display the full data about the select job

i will add gridview control to this page and choose the data source to be the job table and select which fields i want to display

then i will click where to choose the selected row according to the id sent from the previous gridview control on the browse_jobs.aspx

and i click add so that where clause is added to the query then click ok



mohamedbadr.com
Home | contact me
mohamedbadr.com® 2002 - 2006 All Rights Reserved Mohamed BADR ™
2002 FIFA World Cup - Korea and Japan