0
you can create a helper or manager class to separate your business logic from presentation. Write all methods here which are used to interact with data e.g., creating connection firing query or Update operations.
you can create your function let say public DataTable GetDetails(string ContratId) in the helper class. Create a connection to you db and fire a query to get the details of bases on the ContractId and fill the data in DataSet or Datatable what ever you like. and return it.
Now at your presentation call the function and bind the grid with the returned Datatable.
'
Thanks.
Please mark "Do you like this post" if it helps you.
0
Okay but how do we declare it in the second page. And also, how do we declare the business logic for ir? Sorry i do not know how to do it cause I am still new to c#. Thanks!
0
Hi friend,
just don't bind it with contract ID make it little more custom...
you can use Hyperlink in that column and can create the Text='<%#Eval("ContractID")%>' NavigateLink='~\Search2.aspx?ContractId=<%#Eval("ContractID")%>'
and you will have the dynamic url different for each row.
now on the second page you can use Request.QueryString["ContractId"] to fetch the value from URL in page_load event.
and then from your Business logic call a function to load the data based on this ContractID.
Hope this make sense.
Please mark "Do you like this post" if it helps you.
Thanks.
0
Thanks. One of the column in the grid view is being converted to template and I bind it to the ContractID in the database.Is this the way to do it? cause the contract id is being shown. how do we make use of params in the url from the second page and bind to grid. Oh ya i am using 3-tier programming to do it out. Thanks!
0
Hi friend,
you don't have post all your code every time you ask a question just be specific and give the specific region of the code. so that the helper can understand it clearly and quickly.
What i understood with your problem is: You want a link in your first grid and then clicking on that link wanted to show the related data for that particular row in the second page.
Here is the workaround for it:
1. Create a custom column in either you datasource or in gridview itself.
For datasource you can simply add a new column iterate through all rows and fill the values in the column e.g., a link to the second page and the parameters in the url you want on the second page e.g, Contract ID
For gridview approach you have to do the same bt in the Row_Created or Row_Bound event of gridview.
2. Use the params from the url in the second page. and fire the query or whatever source you have to get the data on the basis of the params. and bind your grid.
Hope you got idea from this.
Thanks.