陋室铭
永远也不要停下学习的脚步(大道至简至易)

    找到嵌套的DataList(注:因为第一行为标题,所以第一次行循环找不到DataList 所以才要判断if (DataListDepartment != null))
  protected void score_ItemDataBound(object sender, DataListItemEventArgs e)
{
       DataList DataListDepartment = e.Item.FindControl("DataListDepartment") as DataList;
            if (DataListDepartment != null)
            {
                DataTable DepartmentSingalInformation = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter("Article_DepartmentSingalInformation", myConnection);
                sda.SelectCommand.CommandType = CommandType.StoredProcedure;
                sda.SelectCommand.Parameters.Add(new SqlParameter("@articleID", articleID));
                sda.SelectCommand.Parameters.Add(new SqlParameter("@CreateDepartment", Convert.ToInt32(DepartmentID.Text)));
                sda.Fill(DepartmentSingalInformation);
                DataListDepartment.DataSource = DepartmentSingalInformation;
                DataListDepartment.DataBind();
            }
}

另外在ItemCommand事件中 找到一行和gridview的区别是(GridViewRow WorkGuideGridViewRow = (GridViewRow)((Control)e.CommandSource).Parent.Parent)
        protected void score_ItemCommand(object source, DataListCommandEventArgs e)
        {
            DataListItem DataListItemRow = (DataListItem)((Control)e.CommandSource).Parent;
            Label DepartmentID = DataListItemRow.FindControl("DepartmentID") as Label;
            Label DepartmentName = DataListItemRow.FindControl("DepartmentName") as Label;
            if (e.CommandArgument == "MoreInformation")
            {
 
            }
        }

posted on 2006-10-12 12:33  宏宇  阅读(602)  评论(0编辑  收藏  举报