VS2003基础知识一
实际开发过程中,常常一个数据显示控件(如repeater)显示数据时,常要把(repeater)其中的某个字段的值传到cs文件中去进行数据处理返回想要的结果.
1.aspx文件代码
<asp:repeater id="Repeater1" runat="server">
<ItemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="28%" height="25"><%# DataBinder.Eval(Container.DataItem, "Name") %></td>
<td width="72%">
</td>
</tr>
</table>
<%# BindList((string)DataBinder.Eval(Container.DataItem, "ID"),(string)DataBinder.Eval(Container.DataItem, "Display")) %>
</ItemTemplate>
</asp:repeater>
2. cs文件代码
protected string BindList(string SupportProductID,string Display)//
{
//数据处理
return "数据处理结果";
}
这样就可以在aspx文件直接调用cs文件的方法,返回一些处理后的数据显示在前台.