Question

I am (unfortunately) updating a DotNetNuke 5 desktop module

I have a button handler:

protected void ButtonHandler(object sender, EventArgs e)
{
    Button button = (Button)sender;
    TableCell tblCell = button.Parent;
}

I have also tried the above using NamingContainer - but both options are throwing this error at me:

Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.TableCell'

How can I retrieve the table cell that the button lives in?

Was it helpful?

Solution

You have to cast it :

TableCell tblCell = (TableCell)button.Parent;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top