Everything was work but in some moment stops.
I have GridView and sqldatasource with stored procedure and 4 parameters. DataBind simply not work anymore and gridview is empty. When i copy my stored procedure and make query in code and pass parameters everything is ok!!
Why?

Jignesh KumarRank #91 · 22.9K reputationPosted Jan 17, 2023, 11:59 PM EST
Hello Zeljko,
Please check your SQLDatasourc below property and check,
SQLDatasourc -> Properites -> CancelSelectOnNullParamter = change it to false
Vishal JoshiRank #377 · 6.7K reputationPosted Jan 18, 2023, 12:03 AM EST
Hello
Please try the below code with the respective parameter name to get the store procedure to work with grid view. make sure you set the command type as CommandType.StoredProcedure.
String strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString; SqlConnection con = new SqlConnection(strConnString); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "GetAllEmployeeDetails"; cmd.Connection = con; try { con.Open(); GridView1.EmptyDataText = "No Records Found"; GridView1.DataSource = cmd.ExecuteReader() ; GridView1.DataBind(); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); }Thanks
Sachin SinghRank #66 · 26.2K reputationPosted Jan 18, 2023, 12:25 AM EST
yes, the Default value for CancelSelectOnNullParamter for SQLDatasource is true, you need to make it false.
Naimish MakwanaRank #324 · 7.7K reputationPosted Jan 17, 2023, 11:50 PM EST
Please refer below links. That would help you to solve your problem.
https://stackoverflow.com/questions/7114122/gridview-is-not-displayed-when-using-stored-procedure-in-sqldatasource
https://social.msdn.microsoft.com/Forums/en-US/e1133fb5-a628-41d0-a158-590bc6c76631/problem-with-gridview-and-stored-procedure?forum=aspwebformsdata
Thanks