这是我的列表视图:
public String getTitle(){
return mEtTitle.getText().toString();
}
listview的数据源由dbml存储过程设置。绑定列表视图的函数是
<asp:ListView ID="lstList" runat="server" OnItemDataBound="lstList_ItemDataBound"
OnPagePropertiesChanging="lstList_PagePropertiesChanging">
<LayoutTemplate>
<table border="1" cellpadding="2" cellspacing="0" id="Table1" runat="server"
class="TableCSS" style="width:100%;">
<tr id="Tr1" runat="server" class="TableHeader">
<td>Description</td>
</tr>
<tr id="ItemPlaceholder" runat="server"></tr>
<tr id="Tr2" runat="server">
<td id="Td7" runat="server" align="right" colspan="5" class="TableData">
<asp:DataPager ID="lvDataPager1" runat="server"
PagedControlID="lstList" PageSize="6">
<Fields>
<asp:NumericPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<EmptyDataTemplate>No match</EmptyDataTemplate>
<ItemTemplate>
<tr class="TableData">
<td><asp:Label ID="lblDescription" runat="server"/></td>
</tr>
</ItemTemplate>
</asp:ListView>
我想获取描述值并将其设置为listview标签,但无法执行。
public List<sp_ListResult> GetList(byte id)
{
List<sp_ListResult> results = new List<sp_ListResult>();
var en = dataContext.dc.sp_List(id).GetEnumerator();
while (en.MoveNext())
{
results.Add(en.Current);
}
return results;
}
lstList.DataSource = GetList(id);
答案 0 :(得分:0)
您不是绑定数据表,而是绑定List<class>
,因此必须转换为正确的类型。
sp_ListResult rowView = e.Item.DataItem as sp_ListResult;