Hi,
Could you show me how to get the innertext (company_name) from the legend in the ItemCommand event? I tried the following, but the error is object reference not set.
Here's the partial code that shows the legend:
1.
<
ItemTemplate
>
2.
3.
<
fieldset
style
=
"float:left; width: 480px; height:280px; margin:5px; "
>
4.
5.
<
legend
ID
=
"companyName"
style
=
"color:darkblue; font-weight:bold"
>
6.
<%#Eval("company_name")%><
img
src
=
"../../images/new1.png"
style
=
"width:15px;height:15px"
/>
7.
</
legend
>
Here's the code-behind
01.
protected
void
RadListView1_ItemCommand(
object
sender, RadListViewCommandEventArgs e)
02.
{
03.
// TODO: need to pass leadid to main.
04.
if
(e.CommandName ==
"OpenDetail"
)
05.
{
06.
RadListViewDataItem item = e.ListViewItem
as
RadListViewDataItem;
07.
string
leadId = item.GetDataKeyValue(
"lead_id"
).ToString();
08.
09.
//Label websitelabel = item.FindControl("WebsiteLabel") as Label; // ** accesss ok **//
10.
11.
// ** object reference not set **//
12.
string
leadName = (item.FindControl(
"companyName"
)
as
System.Web.UI.HtmlControls.HtmlGenericControl).InnerText;
13.
14.
// ** Not working **//
15.
//Hashtable table = new Hashtable();
16.
//item.OwnerListView.ExtractValuesFromItem(table, item, true);
17.
//string leadName = table["CompanyLegend"].ToString();
18.
//string leadName = "ABC";
19.
20.
OutcomeEventArgs outcomeEventArgs =
new
OutcomeEventArgs(leadId, leadName);
21.
if
(OpenLeadDetail !=
null
)
22.
OpenLeadDetail(
this
, outcomeEventArgs);
23.
}
24.
25.
}
Thank you,
Helen