views:

434

answers:

1

Many thanks in advance. I've done my due diligence and researched for 2 days, but can't seem to wrap my mind around what online tutorials describe.

The situation: Lead Programmer ups and quits. Owner of firm knows I've done some (novice) VB.NET on the side and asks me to wire up functionality between 2 custom user controls on his intranet app (written in C#. Small consideration for answering pros -- I'm fluent in Visual Studio...but still learning C#).

Here's a simplified description of controls, but hopefully enough to get us going in the right direction:

UserControl_1 contains multiple linkbuttons that, when clicked, should change the value of the SelectParameter being used by an ObjectDataSource in UserControl_2:

<asp:LinkButton ID="OpenBtn1" runat="server" Text="Show Open Requests" />
<asp:LinkButton ID="ClosedBtn1" runat="server" Text="Show Closed Requests" />

UserControl_2 (GridView with DataSource):

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    SelectMethod="GetDataBy_Status" 
    TypeName="adhoc_TblAdptrs.adhoc_TblAdptr">
    <SelectParameters>
       <asp:Parameter DefaultValue="All" Name="status" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>

<asp:GridView1 ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" />

What I'd like to do pass a new default value to the SelectParameter of the the ObjectDataSource in UserControl_2. I'm looking forward to a personalized explanation from the pros! Your help is greatly, greatly appreciated!

+3  A: 
Russ Bradberry
+1. I agree with this answer. Plus one other consideration.. I wonder if both user controls could be combined into one? They seem tightly coupled already...
KP
I thought the same thing until I found that same control used in different places throughout his site where it wouldn't make sense to have the linkbuttons tied in.
Daniel
Russ -- I understand what you suggested thus far, but...don't I need a way to "bubble" the click event of the linkbutton in UserControl_1 up to the page, so that a function on the page can alter the parameter? (I ask that because if UserControl_1 is used in a page where the gridview/ObjectDataSource in UserControl_2 doesn't exists, wouldn't that throw an error?)
Daniel
ok, i edited my post to account for this.
Russ Bradberry
@Daniel, please see my edits, as I have changed a few things and added a better solution that wouldn't require coupling.
Russ Bradberry
Awesome. Thanks, Russ. You've given me very clear instruction. Very, very much appreciated!
Daniel