I'm using a repeater whose item has a button in it. For each button, want it to run the SaveToDatabase()
function of the item in that repeater. Is it possible to bind a lambda to the Command
event of that button?
Here's what my code looks like:
var subRole = item.DataItem as SubRole;
btn_EditRole.Command += (btnSender, args) => subRole.SaveToDatabase();
Trying it out, it throws an exception, but IDK if that's because I'm doing something stupid syntatically or because binding lambdas like this isn't possible.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.