سؤال

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?

هل كانت مفيدة؟

المحلول

You have to cast it :

TableCell tblCell = (TableCell)button.Parent;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top