请问为何执行一个reapeater里面的button的click的时候会先把我之前点击过的dropdownlist 的select事件先执行一遍,然后才会执行button的click,怎样才能只执行click事件? 有没有人遇到过同样问题?希望能有人帮忙解决 谢谢!
解决方案 »
- 求解aspx页面中include一个asp页面的问题
- datalist显示上的一些问题
- 面向对象的问题
- 客户端截图
- Session跨页消失
- Infragistics.WebUI.UltraWebGrid.UltraWebGrid問題?
- 当用户在学院(使用dropdownlist)中选择计算机学院时,再当用户选择系别时(使用dropdownlist)只能在计算机学院中的系别中进行选择,如
- 一个关于cookie的问题,小弟今天晕了,请各位帮帮忙
- 如何在Asp.Net中删除已定义的组件变量,以便重新定义该变量
- 请问高手如何区别:html control ,web control
- 有没有系统或服务提供铁路货运单价和公路货运单价的
- textbox触发onchange事件
<asp:repeater id="Repeater1" runat="server" enableviewstate="False" onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
处理人:
<asp:DropDownList ID="areas" runat="server" thisIndex="<%# Container.ItemIndex %>" OnSelectedIndexChanged="SelectedIndexChanged_area" AutoPostBack="true">
<asp:ListItem Value="">--选择--</asp:ListItem>
<asp:ListItem Value="a">a</asp:ListItem>
<asp:ListItem Value="b">b</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="handler" runat="server">
</asp:DropDownList>
选择类型:
<asp:DropDownList ID="big_type" runat="server" thisIndex="<%# Container.ItemIndex %>" OnSelectedIndexChanged="SelectedIndexChanged_type" AutoPostBack="true">
<asp:ListItem Value="">--选择类型--</asp:ListItem>
<asp:ListItem Value="a">a</asp:ListItem>
<asp:ListItem Value="b">b</asp:ListItem>
</asp:DropDownList>
小类型:
<asp:DropDownList ID="small_type" runat="server">
</asp:DropDownList><asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/images/gengxin.jpg" CommandName="time" ValidationGroup="<%# Container.ItemIndex %>"/>
</ItemTemplate>
</asp:repeater>后台:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{ case "time":
<这里是我的执行代码>
} } protected void SelectedIndexChanged_area(object sender, EventArgs e)
{
DropDownList dl = sender as DropDownList;
int i = int.Parse(dl.Attributes["thisIndex"]);
DropDownList areas = (DropDownList)Repeater1.Items[i].FindControl("areas");
DropDownList handler = (DropDownList)Repeater1.Items[i].FindControl("handler");
DataTable dt = Getdata.data(areas.SelectedItem.Value);
handler.DataSource = dt;
handler.DataTextField = dt.Columns["name"].ToString();
handler.DataValueField = dt.Columns["name"].ToString();
handler.DataBind();//绑定数据库
}
protected void SelectedIndexChanged_type(object sender, EventArgs e)
{
DropDownList dl = sender as DropDownList;
int i = int.Parse(dl.Attributes["thisIndex"]);
DropDownList big_type = (DropDownList)Repeater1.Items[i].FindControl("big_type");
DropDownList small_type = (DropDownList)Repeater1.Items[i].FindControl("small_type");
DataTable dt = Getdata.data(big_type.SelectedItem.Value);
small_type.DataSource = dt;
small_type.DataTextField = dt.Columns["name"].ToString();
small_type.DataValueField = dt.Columns["name"].ToString();
small_type.DataBind();//绑定数据库
}
ImageUrl="~/images/gengxin.jpg" CommandName="time" ValidationGroup="<%# Container.ItemIndex %>"/>
private void ImageButton1_Click(object sender, EventArgs e)
{
response.write("ok");
}
给
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/images/gengxin.jpg" CommandName="time" ValidationGroup="<%# Container.ItemIndex %>"/>
</ItemTemplate>
赋个事件