Tag: selectedindexchanged

DropDownList的SelectedIndexChanged事件不会触发

我的网页中有一个DropDownList对象。 当我点击它并select一个不同的值时,即使我有一个连接到SelectedIndexChanged事件的函数,也没有任何反应。 我会尝试尽可能有序地在这里发布我的代码: 首先,实际对象的HTML代码: <asp:DropDownList ID="logList" runat="server" onselectedindexchanged="itemSelected"> </asp:DropDownList> 这就是这个函数, itemSelected : protected void itemSelected(object sender, EventArgs e) { Response.Write("Getting clicked; " + sender.GetType().ToString()); FileInfo selectedfile; Response.Write("<script>alert('Hello')</script>"); foreach (FileInfo file in logs) { if (file.Name == logList.Items[logList.SelectedIndex].Text) { Response.Write("<script>alert('Hello')</script>"); } } } 没有一个响应出现,并且这部分JavaScript从未运行。 我已经在最新的3.6版本的Firefox以及Internet Explorer 8上尝试了这一点。这是从Windows Server 2003 R2机器上运行,运行ASP.Net和.NET Framework版本4。 如果任何人都可以帮助,那会很好。

如何在没有selectbutton的情况下在GridView中实现全行select?

我正在实现一个function,当用户按下GridView中的行中的任何一点,行将被选中,而不是selectbutton。 为了实现这一点,我使用下面的代码: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Set the hand mouse cursor for the selected row. e.Row.Attributes.Add("OnMouseOver", "this.style.cursor = 'hand';"); // The seelctButton exists for ensuring the selection functionality // and bind it with the appropriate event hanlder. LinkButton selectButton = new LinkButton() { CommandName = "Select", […]