关于DataList的嵌套 和(ItemCommand)事件的问题
2006-10-12 12:33
591 查看
找到嵌套的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")
{
}
}
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")
{
}
}
相关文章推荐
- DataList的问题 - ItemCommand事件不响应
- 嵌套在DataList1里的DataList2的ItemDataBound事件编写注意问题.
- Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- 我的Android进阶之旅------>Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- 关于DataList嵌套DataList的问题(重点在于处理某些特殊结构与数据绑定)
- 关于Listbox的 SelectionChanged 事件 (同一个Item只触发一次问题)
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- 刚刚发现的一个小问题的解决办法(datalist绑定和itemcommand)
- 关于listitem点击事件根据position取得数据库数据Onresume()更新Adapter后取得数据错误的问题
- Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
- 自定义SwipeRefreshLayout 嵌套listview 并解决item点击事件焦点冲突问题
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- 我的Android进阶之旅------>Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- DataGrid嵌套DataList,子DataList控件中的ItemDataBound事件的问题
- DataList Web--OnItemCommand 事件
- ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- 关于ASP.NET里面的onmenuitemclick事件不被触发的问题
- 关于解决多个viewpager嵌套所遇到的事件传递问题
- 关于ListView嵌套ListView,外层Item点击事件的冲突解决