Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve data in detailsview on click of hyperlink

Status
Not open for further replies.

venuchalla

Programmer
May 30, 2006
29
FR
Hello,
I am having a GridView in which the data is shown is coming from two tables
The gridview has only one column.
DESCRIPTION.
I have added one hyperlink column ,details to the gridview,
When I click on that hyperlink , I have to go to the detailsview of that purticular record selected from which table it is.

Because there are two tables, I am not knowing how to do this...Can anyone please help me..

Thanks,
 
very confusing post. What is the data look like from the 2 tables? What data is shown in the grid? What do you want to show when you click the link?
 
My query is

"SELECT SUBSTRING(Issues.Description,1,100) AS Description FROM Issues WHERE Issues.Description LIKE '%" + TextBox1.Text + "%'"
+ "UNION "
+ "SELECT SUBSTRING(ScheduledEvents.Information,1,100) AS Description FROM ScheduledEvents "
+ "WHERE ScheduledEvents.Information LIKE '%" + TextBox1.Text + "%'"
You can see there are two tables the data is shown in Gridview.

Now I have issuesdetailsview.aspx for records in issues table.
And I have eventsdetailsview.aspx for records in scheduledevents.

There is a text box and searchbutton.
I enter some text in the textbox and click on the searchbutton, the data is retrieved into the gridview using the above query.

What I want is I have added one hyper link column to the gridview , when I click on the hyperlink it has to take me to the appropriate record selected in the gridview and that purticular .aspx page has to come up.

For example if i click on any record in the gridview description's hyperlink, if it the result of a issues table then it has to take me to the details page of issues .

Hope I am clear, can you please tell me how can i do this..
and
 
If you are only returning one column, as you have shown, there is NO way to know which table it came from. You will have to modify the query to include another column, say "Table" varchar(20). Set that column to the table name the other value comes from.
Code:
SELECT  SUBSTRING(Issues.Description,1,100)   AS Description, "Issues" as TableName FROM   Issues WHERE  Issues.Description LIKE ...
UNION
"SELECT   SUBSTRING(ScheduledEvents.Information,1,100)     AS Description,"ScheduledEvents" as TableName FROM   ScheduledEvents "
+ "WHERE  ScheduledEvents.Information  LIKE  ...
On the front end, include that column in the grid, but in the Page_Load, set that column's visible Property to FALSE. This way you can still retieve that value and call your next page
 
I have done the same way you suggested, now How should i goto that purticular details view on click on the hyperlink.

Thanks
 
i want to show that record selected in the detailsview
 
Well, since you don't have an ID column, it could be messy. But what you need to do (basically):
Get the description and tablename on the row when the hyperlink is clicked. Pass those 2 values in the querystring to the next page. Get the values and construct your sql:

Select cols
from "The table you passed"
where column = "description you passed"\

Then just display the results however you like.
 
Can you please help me how to form the query sting with description and table name .

I am having eventsdetails.aspx and issuesdetails.aspx .
depending on the selection of the record that purticular .aspx page should be called.

where should I write this sql query too.

I am not knowing please help me..
 
Hello,
I have written the query string for the hyperlink "details"
like this, but I am not able to get anything, am i doing something wrong????

<asp:HyperLinkField NavigateUrl="~/SearchDetails.aspx?description={0},id={1},tablename={2}"
Text="details" />

when I click on the details link how can I get the details of that record selected, the records are coming from more than one tables
..
Please help????
 
Thanks, Now I could get the query string and pass the bound fields values to the details page.

I should not show the tablename column in the searchpage,
when i write the sqlquery , i am getting the tablename column also displayed inthe frontend.

I tried to make the tablename visible property to false but it shows that the gridview has only one column in it which is hyperlink and the rest of the columns are dynamically generated by the sql query.

How do I make the tablename property false or not show the tablename column in the frontend, but still i want the value to be passed to the second page...

 
You just have to set the visible property of the tablename column to FALSE. In order to still retreive the values in that column, you can't use the designer to set it to false. In the Page_Load event set the visible property of that column to false.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top