Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 28, 2012 12:33 AM by Decker Dong - MSFT
Apr 26, 2012 08:23 AM|LINK
I have the below code writted on the Button click event.
SqlDataSource3.SelectCommand = "SELECT * FROM [IDMServices] WHERE Region='" + DropDownList1.SelectedValue + "' and Country ='" + DropDownList2.SelectedValue + "'";
I need to check if the above query returns any value or returns null? For this the Selected event does'nt get fired, which gives the affeted rows.
protected void SqlDataSource3_Selected(object sender, SqlDataSourceStatusEventArgs e)
int ef = e.AffectedRows;
Apr 26, 2012 09:18 AM|LINK
I guess it'd be called when you bind the data to a control like:
Apr 26, 2012 09:58 AM|LINK
I am not using a Gridview.
Apr 26, 2012 10:10 AM|LINK
Well then you must be using some UI control to display the data correct?
Use its DataBind method.
Apr 28, 2012 12:33 AM|LINK
If you are not using GridView or something like this，I think you can just use a common SqlCommand to check whether rows are effected or not by checking its count：
using (SqlCommand cmd = new SqlCommand("SELECT count(Your Primary Key Name) FROM [IDMServices] WHERE Region='" + DropDownList1.SelectedValue + "' and Country ='" + DropDownList2.SelectedValue + "'",new SqlConnection(“…………”)))
int count = (int)cmd.ExecuteScalar();
//Do what you want here…………