Click here to Skip to main content
15,909,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables: First table called MainDataTable which has 3 columns: id, queryId (FK from DetailedDataTable table), details

Second table called DetailedDataTable which has 3 columns : queryId, Name, Query

Now on page MainDataPage.aspx I have GridView named gridview1 which is showing MainDataTable table values. When I click on 'details' column link (I took that as a Itemtemplate Hyperlink) it goes to new page called DetailedDataPage.aspx which is having new GridView gridview2.

Now gridview2 has to show output which will come from query which is stored into DetailedDataTable table in Query column

for example.

MainDataTable
id queryId details
1 5 select company (this is itemtemplate taken as a Hyperlink)

When I click on above Hyperlink It is going on DetailedDataPage which is having gridview2 and data coming on gridview2 is running Query column from DetailedDataTable

DetailedDataTable
queryId Name Query
5 Mycom select companyname from CompantTable

Now I want to run select companyname from CompantTable and show this output to gridview2 when i click on select company (this is itemtemplate taken as a Hyperlink) from MainDataTable .
Posted
Updated 25-Aug-11 0:49am
v2

Follow the Steps below...

1. First Fill the Grid of the page MainDataPage.aspx, In this Grid Pass the Id Of MainDataTable with the Navigate Url.
2. Make a Stored Proc to Select the Query that you have already stored in DetailedDataTable

that may look like

SQL
CREATE PROC [dbo].[SP_SelectQuery] 
    @Id INT
AS
BEGIN
    DECLARE @eQuery NVARCHAR(MAX)
    SET @eQuery=(SELECT Query FROM dbo.DetailedDataTable DDT INNER JOIN dbo.MainDataTable MDT ON
    DDT.QueryId=MDT.QueryId WHERE MDT.Id=@Id)
    EXEC(@eQuery)

END
GO


3. In DetailedDataPage.aspx take another grid and fill that grid with the above written stored proc by passing the Id value that you have given in Navigate Url of First MainDataPage.aspx.

Hope this would help you.
 
Share this answer
 
1.Create a Store Procedure to the table
2.Write a Function linqmapper
3.pass the query in frontend(update,delete,insert)
 
Share this answer
 
for your query i need some screenshot or some graphical understandable content.
this not tough but difficult to understand your question...
 
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