Imports SidriWeb.sidriNameSpace
Public Class testDatalist
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents DataList1 As System.Web.UI.WebControls.DataList
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Public nnn As Date
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Not Page.IsPostBack Then
binddatalist()
End If
End Sub
Private Sub DataList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataList1.SelectedIndexChanged
DataList1.EditItemIndex = -1
binddatalist()
End Sub
Private Sub binddatalist()
ObjSql.strSQL = "select * from department"
If DataList1.SelectedIndex >= 0 Or DataList1.EditItemIndex >= 0 Then
ObjSql.strSQL = "select D.*,E.realname from department D left join employee E on D.dpthead=E.userid "
End If
Dim dr As SqlClient.SqlDataReader = ObjSql.SelectFromDBrd()
DataList1.DataSource = dr
DataList1.DataKeyField = "dptid"
DataList1.DataBind()
dr.Close()
If DataList1.SelectedIndex >= 0 Then
Dim dli As DataListItem = DataList1.Items(DataList1.SelectedIndex)
Dim litdpthead As Literal = DirectCast(dli.FindControl("litdptheadp"), Literal)
If Not IsNumeric(litdpthead.Text) Then
Dim Label7 As Label = DirectCast(dli.FindControl("Label7"), Label)
Label7.Text = "无部门领导"
End If
End If
If DataList1.EditItemIndex >= 0 Then
Dim dli As DataListItem = DataList1.Items(DataList1.EditItemIndex)
Dim Ddldpthead1 As DropDownList = DirectCast(dli.FindControl("Ddldpthead"), DropDownList)
FillListControl(Ddldpthead1, "employee", "Realname", "userid")
Ddldpthead1.Items.Insert(0, New ListItem("无部门领导", "-100"))
Dim litdpthead As Literal = DirectCast(dli.FindControl("litdpthead"), Literal)
If IsNumeric(litdpthead.Text) Then
SelectItemFromvalue(Ddldpthead1, litdpthead.Text)
Else
Ddldpthead1.SelectedIndex = 0
End If
End If
End Sub
Private Sub DataList1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.EditCommand
DataList1.SelectedIndex = -1
DataList1.EditItemIndex = e.Item.ItemIndex
binddatalist()
End Sub
Private Sub DataList1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.CancelCommand
DataList1.EditItemIndex = -1
DataList1.SelectedIndex = -1
binddatalist()
End Sub
End Class