在DataBound中实现
和平时用的没有两样.
就是注意实例化你的DropdwonList
和平时用的没有两样.
就是注意实例化你的DropdwonList
解决方案 »
- 帮帮忙吧!!!DetailsView的模板列里放置Lable的赋值并显示的问题
- ASP.NET 如何操作DBF数据库字段名中存在“.”字段
- .net连接mysql数据库,用过的进来说下!
- 如何在特定的一段文字中,按照事先指定的关键字加上指定的链接?
- 请高手来帮帮我,问题很棘手,希望有高手会!在线等。。。急~~~
- 未能找到元素“log4net”的架构信息,在线等,先谢了。
- 很幼稚的一个问题,我用什么数据类型好呢?
- 万分求一句SQL
- RadioButtonList的SelectedIndexChanged事件中如何取当前选中项的值?急!!!
- treeview动态捆绑数据
- 济南的.NET人员请进来
- 我把word存进SQL数据库里面,用SQL全文检索功能进行检索,怎么设置全文检索和写查询的SQL语句啊,最好给个源代码
dropdownlist是datagrid里的模板
if(e.Item .ItemType ==ListItemType.Header )
{
DropDownList dep=(DropDownList)e.Item .FindControl ("dept");
dep.SelectedIndexChanged+=new EventHandler(dep2_SelectedIndexChanged);
===============>
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType ==ListItemType.AlternatingItem)
{
....
}
For i = 0 To n
AddHandler CType(dgListArticle.Items(i).Cells(5).FindControl("DropDownList1"), DropDownList).SelectedIndexChanged, AddressOf DropDownList1_selectchange
Nextprivate sub DropDownList1_selectchange(ByVal sender As Object, ByVal e As System.EventArgs)
binddrop2(CType(sender, DropDownList).SelectedItem.Text)
end sub
怎么把 第一个dropdownlist 的参数传递给第二个 dropdownlist呢
'************************************ checkbox
Dim mycheckbox As CheckBox
mycheckbox = e.Item.FindControl("tcb")
Response.Write(mycheckbox.Text)
If mycheckbox.Checked Then
mycheckbox.Text = "Male"
Else
mycheckbox.Text = "Female"
End If
'************************************
'******************************************* DropDownList
Dim myLst As DropDownList = CType(e.Item.FindControl("tddl"), DropDownList)
Dim myRow As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim lbl As RadioButton = CType(e.Item.FindControl("rdo"), RadioButton) myLst.DataTextField = "birthday"
myLst.DataValueField = "birthday" myLst.DataSource = GetRoles(lbl.Text) myLst.DataBind()
'*******************************************
'****************** labelradiobutton
Dim myLbl As Label
myLbl = e.Item.FindControl("lblRad")
myLbl.Text = "<input type=radio name='myradiogroup' value=" & e.Item.ItemType & ">"
'****************** End If
'********************************* We only want to run this code for items in edit mode
If (e.Item.ItemType = ListItemType.EditItem) Then
'*********************
'Locate our DropDownList
Dim myList As DropDownList = CType(e.Item.FindControl("Eddl"), DropDownList) 'Grab the current row of data - we need that so we know what value to select in the ddl
Dim myRow As DataRowView = CType(e.Item.DataItem, DataRowView) 'Set the Text and Value field for our DropDownList
myList.DataTextField = "birthday"
myList.DataValueField = "birthday"
'Fill our DropDownList with the standard list of data
myList.DataSource = GetRole() Dim aaaa As Integer = myRow.DataView.Count() myList.DataBind()
myList.Items.Add("")
myList.SelectedIndex = (aaaa - 1)
'********************** '****************** labelradiobutton
Dim myLbl As Label
myLbl = e.Item.FindControl("lblRad")
myLbl.Text = "<input type=radio name='myradiogroup' value=" & "e.Item.ItemType" & ">"
'****************** '************************************ checkbox
Dim mycheckbox As CheckBox
mycheckbox = e.Item.FindControl("tcb")
Response.Write(mycheckbox.Text)
If mycheckbox.Checked Then
mycheckbox.Text = "Male"
Else
mycheckbox.Text = "Female"
End If
'************************************ End If
'********************************* End Sub
Public Function GetRole() As DataView
StrSql = "SELECT "
StrSql = StrSql & "birthday "
StrSql = StrSql & "FROM MTXL "
Dim Comm As OleDbDataAdapter = New OleDbDataAdapter(StrSql, Str)
Dim ds As DataSet = New DataSet()
Comm.Fill(ds, "Roles")
Return ds.Tables("Roles").DefaultView
End Function Public Function GetRoles(ByVal aaa As String) As DataView
StrSql = "SELECT "
StrSql = StrSql & "birthday "
StrSql = StrSql & "FROM MTXL "
StrSql = StrSql & "where id='" & aaa & "'"
Dim Comm As OleDbDataAdapter = New OleDbDataAdapter(StrSql, Str)
Dim ds As DataSet = New DataSet()
Comm.Fill(ds, "Roles")
Return ds.Tables("Roles").DefaultView
End Function
1.在 DataGrid的 ItemCreated 事件中为每行的 dropDownList1 和 dropDownList2 的 SelectedIndexChanged 事件 委托,并且绑定 dropDownList1。
在 ItemCreated 事件里写:
if(e.Item .ItemType ==ListItemType.Header )
{
DropDownList dropDownList1=(DropDownList)e.Item .FindControl ("dropDownList1");
dropDownList1.SelectedIndexChanged+=new EventHandler(dropDownList1_SelectedIndexChanged);
DropDownList dropDownList2=(DropDownList)e.Item .FindControl ("dropDownList2");
dropDownList2.SelectedIndexChanged+=new EventHandler(dropDownList2_SelectedIndexChanged);2.在 dropDownList1 的 SelectedIndexChanged事件里面绑定相应行的 dropDownList1 至于怎么样将 dropDownList1 的选择的值传到 dropDownList2 可以用 dropDownList1.Parent.Parent 找到相应的行即 DataGrid.Item,知道了 Item 即可用 FindControl("ID")找到你想要的任何 web 控件。
if(e.Item .ItemType ==ListItemType.Header )
改成
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType ==ListItemType.AlternatingItem)
我只会 C# ,VB不懂