I recently created a webform that added, updated, and deleted records as needed from a SQL Server 2000 database. After each addition, modification, or deleteion a datagrid and table would be shown with the new data.
After spending some time reading up on test driven development and refactoring I recreated the code using a class libary so that the code could be reused as needed. It runs faster and is much prettier as well. The problem I have is that the code-behind page is calling the class; but I have no idea on how to set the datagrid and tables values from within the class.
My first thought is to return mulitple variables from the class and allow the code-behind to continue setting the table and datagrid values as before, but I'm not really sure on how to return mulitple variables from a class.
It seems that there should be a way to set thoses vars from within the class. I have tried "borrowing" from the code behind by adding imports to the System.Web namespace and haveing it inherit System.Web.UI.Page as well. I have also setup Protected withevents for the table object (I'm tring the table first). It just seems as though the class doesn't "see" or have a "connection" to the page. It errored by saying "Specified argument was out of the range of valid values. Parameter name: index" the code that called it was:
dim strcbcount as string = "test"
Me.table2.Rows(1).Cells(1).Text = strcbcount
The table has been working using the codebehind so there is actually a row 1, cell 1.
I was thinking there should be a namespace I could use sort of like the GetBrowser that is used with the Nunit framework. Something like:
dim page as namespace.GetPage("page.aspx")
page.table1.cells(0).row(0).text = "hello"
I have searched all over the net but I'm afraid that I'm not looking right since this is hard to explain, let alone narrow for a search.
Thanks for your time, patience, any help,
wraheem
After spending some time reading up on test driven development and refactoring I recreated the code using a class libary so that the code could be reused as needed. It runs faster and is much prettier as well. The problem I have is that the code-behind page is calling the class; but I have no idea on how to set the datagrid and tables values from within the class.
My first thought is to return mulitple variables from the class and allow the code-behind to continue setting the table and datagrid values as before, but I'm not really sure on how to return mulitple variables from a class.
It seems that there should be a way to set thoses vars from within the class. I have tried "borrowing" from the code behind by adding imports to the System.Web namespace and haveing it inherit System.Web.UI.Page as well. I have also setup Protected withevents for the table object (I'm tring the table first). It just seems as though the class doesn't "see" or have a "connection" to the page. It errored by saying "Specified argument was out of the range of valid values. Parameter name: index" the code that called it was:
dim strcbcount as string = "test"
Me.table2.Rows(1).Cells(1).Text = strcbcount
The table has been working using the codebehind so there is actually a row 1, cell 1.
I was thinking there should be a namespace I could use sort of like the GetBrowser that is used with the Nunit framework. Something like:
dim page as namespace.GetPage("page.aspx")
page.table1.cells(0).row(0).text = "hello"
I have searched all over the net but I'm afraid that I'm not looking right since this is hard to explain, let alone narrow for a search.
Thanks for your time, patience, any help,
wraheem