我有一个带有postback = true属性的dropdownlist,它有selectedindexchange事件,我也有onClick事件的按钮。问题是按钮点击触发我的下拉列表事件,我不想要它。 在selectedindexchange中我有一些删除查询,它与按钮点击事件代码无关。
这是我的databind下拉列表:
<asp:dropdownlist ID="DropDownList1" EnableViewState="true" AutoPostBack="true" runat="server" DataSourceID="SqlDataSource1" Width="200"
DataTextField="NAME" DataValueField="ID" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:dropdownlist>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db_conn %>"
SelectCommand="SELECT [ID], [NAME] FROM [TABLE] ORDER BY [ID]">
</asp:SqlDataSource>
这是按钮点击代码
protected void btnUpdate_Click(object sender, EventArgs e)
{
IFormatProvider culture = new CultureInfo("en-US");
SqlParameter[] arp = new SqlParameter[6];
arp[0] = new SqlParameter("@number", SqlDbType.NChar, 10);
arp[0].Value = txtNumber.Text;
arp[1] = new SqlParameter("@date", SqlDbType.SmallDateTime);
arp[1].Value = Convert.ToDateTime(Date.Value, culture);
// arp[4] = new SqlParameter("@keywords", SqlDbType.SmallDateTime);
// arp[4].Value = Convert.ToDateTime(Date.Value, culture);
int doc_id = 0;
try
{
doc_id = Int32.Parse(hidenDocID.Value);
}
catch
{
}
arp[2] = new SqlParameter("@doc_id", SqlDbType.Int);
arp[2].Value = doc_id;
arp[3] = new SqlParameter("@text", SqlDbType.NText);
arp[3].Value = FCKeditor1.Value;
arp[4] = new SqlParameter("@type_id", SqlDbType.Int);
arp[4].Value = Int32.Parse(DropDownList1.SelectedValue);
arp[5] = new SqlParameter("@id", SqlDbType.Int);
arp[5].Value = Int32.Parse(lawId);
#endregion
try
{
SqlHelper.ExecuteNonQuery(connString, CommandType.StoredProcedure, "update_document", arp);
UpdateCategory(Convert.ToInt32(lawId));
}
catch (Exception adEx)
{
lblMessage.Text = adEx.ToString();
}
}