Using Parameters of FormParameter type with ObjectDataSource Control on pages that use Master pages.

 

Recently we got a case where customer is trying to use FormParameters with DataSource controls on pages that uses Master Pages. It is by design that the Form Parameters will generate null values because of Master Pages. You can find the Bug details with a possible workaround at:

http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=d2f2feaa-f0c8-466d-bfd8-26035e5dec97

Besides that, i have recently posted another workaround at http://lab.msdn.microsoft.com/ProductFeedback/ViewWorkaround.aspx?FeedbackID=FDBK20164#2.

Brief workaround description

"We will first check whether the Page is inheriting the Master page. If yes, then we will load all the FormFields inside FormParameters at runtime declared under the template section of SQLDataSource control. After doing that, we will run a FindControl on the Master Page to get the Text for all the FormFields. After we get hold of the text we can set the default value for that form parameter with the text.
I agree that it will be slow as compared to the first workaround but here we don't have to hardcode the values in the FormField
"