on 12-16-2004 7:08 PM
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.
I assume you're probably didn't set a needed property in your initialization. Maybe the TableRow key? or the cells key...?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.