在DataGrid的模板列中加入的DropDownList控件
<asp:DropDownList runat="server" id="ddl" AutoPostBack="True" OnSelectedIndexChanged="ddl_SelectedIndexChanged" />
然后你在.aspx.vb中加入一个函数















上面的代码功能是获得当前响应的DropDownList在DataGrid中的行index值,并处理相关方法。
实现方法是通过循环判定.DataGrid中为每个子控件唯一指定的UniqueID值是否与当前选定的DropDownList的UniqueID相等。
2006-07-07:最近又找到一个更方便的方法,只要通过增加事件就可以了
看上面的代码,在
dim DdListDg as DropDownList
DdListDg=CType(dgMsg.Items(i).FindControl("ddl"),DropDownList)后面
增加事件
AddHandler DdListDg.SelectedIndexChanged, AddressOf Update
然后定义要执行的sub就行
Private Sub Update()
' 写要用的代码
End Sub