Setting SqlDataSource"s Parameter values manually

Written on November 13, 2005

Today I wanted to set the SqlDataSource SelectParameter's values manually without using a databound control like GridView - actually I came to this solution:

private void DoSomeThing(int ParentMenuID) {
SqlDataSource1.SelectParameters.Add("ParentID", TypeCode.Int32, ParentMenuID.ToString());

Of course, if you're working with a databound control like GridView, you should use the GridViews Events like Selecting, Updating etc. to modify the parameters values passed to the SqlDataSource-Control.

And of course using the SqlDataSource is not the best design for an application's code reusability ;-)