Hi Haim,
From your post, I understand that you're binding a GridView to an
ObjectDataSource which has a ControlParameter associated to a
DropDownList.SelectValue. And you don't want the ObjectDataSource to
retrieve data on first page load. Please feel free to post here if I've
misunderstood anything.
First, if you are using declarative syntax to configure the
ObjectDataSource and associate it with the DropDownList, I don't think you
can prevent it from reading data the first time. As far as I know, there's
no event in the ObjectDataSource that you can cancel the data binding.
However, you can prevent the GridView to bind to the ObjectDataSource the
first time by:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSourceID = "";
}
else
{
GridView1.DataSourceID = "ObjectDataSource2";
}
}
The ObjectDataSource will still read the data but the result is not shown
in the GridView on the first page load.
If you need to completely prevent the ObjectDataSource from loading data on
first page load, you have to construct the ObjectDataSource dynamically. I
will depict more on this if you need information on this.
Sincerely,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.