Last post Mar 04, 2012 01:37 AM by Decker Dong - MSFT
Mar 02, 2012 06:02 AM|rpk2006|LINK
I am using PetaPoco. While PetaPoco manages separation of UI with the DAL, I am often confused with the code associated with a server control.
I want to keep loose coupling and don't want code to be tightly integrated with the UI. For instance,
I have a GridView control on my WebForm. The GridView control has Button Fields. When a button associated with a row is clicked, a Command is raised and this code is executed:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
if (e.CommandName == "GetSelectedRowDetails")
int currentRowIndex = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = GridView1.Rows[currentRowIndex];
TableCell recordID = selectedRow.Cells;
string RecordID = recordID.Text;
reuse reuse = new reuse();
Here again I wonder whether the code is tightly coupled or loose. I want to know where should I put this code. How to bind events to a class?
Mar 04, 2012 01:37 AM|decker dong - msft|LINK
I don't think it's too tightly integrated with UI in the RowCommand event。Because you have to have some codes that fetch values from the GridViewRow.Cell's value and pass them as parameters into the method that executes CRUD。
In my mind，the defination of "too tightly integrated with UI" is——You've written from connection to CRUD to UI，no any methods or DLL files at all。