cancel
Showing results for 
Search instead for 
Did you mean: 

Table.LeadSelect event crashes (with no code)

Former Member
0 Kudos

Hi,

I have a table with 1 column that I have populated

I added the LeadSelect event handler and if I click on an item in the table it now crashes (error info below)

I have no code in the handler it is just the autogenerated stub VS gives you

Anyone seen this or have any idea what might be happening?

Is there an alternative to this in order to get a cell\row click event?

Vin

Server Error in '/EPApp1001' Application.

-


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

SAP.Web.UI.Controls.TableBodyCell.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +95

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138

System.Web.UI.Page.ProcessRequestMain() +1277

-


Version Information: Microsoft .NET Framework Version:1.1.4322.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I assume you're probably didn't set a needed property in your initialization. Maybe the TableRow key? or the cells key...?

Former Member
0 Kudos

Gave the TableRow a Key

The cell class doesn't have a key property

made no difference

On second look through, it looks like the 'RaisePostBackEvent' handler might be the null bit

but I have no idea how to set that!

Vin

Former Member
0 Kudos

OK... this exception is caused since you never set the index of the table cell.

First set the property of the table "SelctionMode" to "single". Now... update your code a little (mostly notice the TableBodyCell Constructor, and the TableRow key):

// Add the "titles" ...

TableCell t1 = new TableCell();

t1.Title = "t1";

TableCell t2 = new TableCell();

t2.Title = "t2";

Table1.ItemTemplate.Cells.Add(t1);

Table1.ItemTemplate.Cells.Add(t2);

// Add a row

TableRow tr = new TableRow();

tr.Key = "A"; // this will be used to identify what was clicked

TableBodyCell c1 = new TableBodyCell(Table1,tr,0);

c1.TableCellContent = new TextView("c1");

tr.Cells.Add(c1);

TableBodyCell c2 = new TableBodyCell(Table1,tr,1);

c2.TableCellContent = new TextView("c2");

tr.Cells.Add(c2);

Table1.Items.Add(tr);

// Add another row

tr = new TableRow();

tr.Key = "B";

...

And to get the selected row key use the LeadSelect event:

private void Table1_LeadSelect(...)

{

Response.Write("Checked" + Table1.SelectedKeys[0]);

}

Hope this helped,

Ofer

Former Member
0 Kudos

That is perfect.

Thanks, Vin

Answers (0)