ItemDataBound为何不起作用?
.cs文件
--------------------------------
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings[ "connStr "]);
String cmdStr = "Select * From Pro_Type Where ParentID Is Null ";
SqlDataAdapter cmd = new SqlDataAdapter(cmdStr, conn);
DataSet ds = new DataSet();
cmd.Fill(ds, "Pro_Type ");
protype.DataSource = ds;
protype.DataBind();
conn.Close();
}
}
private void protype_ItemDataBound(object Sender, DataListItemEventArgs e)
{
Response.Write( "asdfasdfasfasdfasdfd??? ");
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataList childlist = (DataList)e.Item.FindControl( "childlist ");
//找到分类Repeater关联的数据项
DataRowView rowv = (DataRowView)e.Item.DataItem;
//提取分类ID
int ParentID = Convert.ToInt32(rowv[ "ParentID "]);
//根据分类ID查询该分类下子类,并绑定chil