• 关于DataList的嵌套 和(ItemCommand)事件的问题


        找到嵌套的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")
                {
     
                }
            }

  • 相关阅读:
    传说中的WCF(12):服务器回调有啥用
    传说中的WCF(11):会话(Session)
    传说中的WCF(10):消息拦截与篡改
    传说中的WCF(9):流与文件传输
    传说中的WCF(8):玩转消息协定
    传说中的WCF(7):“单向”&“双向”
    传说中的WCF(6):数据协定(b)
    传说中的WCF(5):数据协定(a)
    传说中的WCF(4):发送和接收SOAP头
    测试工作绝不仅限于点点点!
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/527188.html
Copyright © 2020-2023  润新知