学习 aspnet 快速入门的时候 ,第七讲 有一段代码是将一个
bulletlist 控件 与一个数据源绑定 , 苏老师使用 vb写的 ,我向c#转换时 碰到了问题 代码如下 :
Sub employeesGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
' For each DataRow in the GridView, programmatically access the BulletedList, filter
' the DataView based on the GridView row's EmployeeID value and bind the filtered DataView
' to the BulletedList
If e.Row.RowType = DataControlRowType.DataRow Then
Dim bl As BulletedList = CType(e.Row.FindControl("bltTerritories"), BulletedList)
territoryData.RowFilter = "EmployeeID = " & CType(e.Row.DataItem, DataRowView)("EmployeeID").ToString()
bl.DataSource = territoryData
bl.DataBind()
End If
End Sub我只写了这么多
public void employeesGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
BulletedList bl=(BulletedList)(e.Row.FindControl("bltTerritories"));
TerritoryData="employeedid=" +(DataSourceView)()
}
}谢了阿
bulletlist 控件 与一个数据源绑定 , 苏老师使用 vb写的 ,我向c#转换时 碰到了问题 代码如下 :
Sub employeesGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
' For each DataRow in the GridView, programmatically access the BulletedList, filter
' the DataView based on the GridView row's EmployeeID value and bind the filtered DataView
' to the BulletedList
If e.Row.RowType = DataControlRowType.DataRow Then
Dim bl As BulletedList = CType(e.Row.FindControl("bltTerritories"), BulletedList)
territoryData.RowFilter = "EmployeeID = " & CType(e.Row.DataItem, DataRowView)("EmployeeID").ToString()
bl.DataSource = territoryData
bl.DataBind()
End If
End Sub我只写了这么多
public void employeesGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
BulletedList bl=(BulletedList)(e.Row.FindControl("bltTerritories"));
TerritoryData="employeedid=" +(DataSourceView)()
}
}谢了阿
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
BulletedList bl=(BulletedList)(e.Row.FindControl("bltTerritories"));
TerritoryData="employeedid=" +((DataSourceView)(e.Row.DataItem))["EmployeeID"].ToString();
bl.DataSource = territoryData;
bl.DataBind();
}
}