Home All Groups Group Topic Archive Search About

Passing data into a custom control

Author
5 Apr 2006 7:08 PM
Steve
I made a custom web control (ascx) that contains a bound gridview in a
scrolling panel with a datasource control. This control will be used by
several pages in my site. Each time it is used a different SQL query
(filter) is required.  Now the sqldatasource.selectcommand has the filter
hardcoded into the ascx file. I know this is bad. How can I change the
sqldatasource's selectcommand property dynamically from the pages that will
contain my custom control?

Author
5 Apr 2006 9:25 PM
Steve C. Orr [MVP, MCSD]
The best way is to make a public property or method in the control which
sets the value in the subcontrol.  The page can then call the public
property or method.

Here's more detail:
http://SteveOrr.net/faq/PassDataToUserControl.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


Show quoteHide quote
"Steve" <Steve@nospam.com> wrote in message
news:OAjmJROWGHA.2180@TK2MSFTNGP02.phx.gbl...
>I made a custom web control (ascx) that contains a bound gridview in a
>scrolling panel with a datasource control. This control will be used by
>several pages in my site. Each time it is used a different SQL query
>(filter) is required.  Now the sqldatasource.selectcommand has the filter
>hardcoded into the ascx file. I know this is bad. How can I change the
>sqldatasource's selectcommand property dynamically from the pages that will
>contain my custom control?
>