Last post Apr 27, 2012 08:33 PM by Decker Dong - MSFT
Apr 26, 2012 04:23 AM|ashiqf|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 05:18 AM|nijhawan.saurabh|LINK
I guess it'd be called when you bind the data to a control like:
Apr 26, 2012 05:58 AM|ashiqf|LINK
I am not using a Gridview.
Apr 26, 2012 06:10 AM|nijhawan.saurabh|LINK
Well then you must be using some UI control to display the data correct?
Use its DataBind method.
Apr 27, 2012 08:33 PM|Decker Dong - MSFT|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…………