Hi,
Thank you for your post.
Based on my understanding, your question is how to pass the UserControl's
property to its SqlDataSource as one of its select parameters. If I've
misunderstood anything, please feel free to post here.
I recommend you handle the SqlDataSource's Selecting event and set the
select parameter value there. Also, you need to call DataGrid.DataBind()
after the UserControl's property gets changed.
I'm using SqlServer NorthWind database "Order Details" as an example:
<asp

ataGrid ID="grid1" runat="server"
DataSourceID="SqlDataSource1"></asp

ataGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT * FROM [Order Details] WHERE ([OrderID] =
@OrderID)" OnSelecting="SqlDataSource1_Selecting">
<SelectParameters>
<asp

arameter Name="OrderID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
public int OrderID
{
get
{
object o = ViewState["OrderID"];
if (o == null) return 0;
return (int) o;
}
set
{
ViewState["OrderID"] = value;
grid1.DataBind();
}
}
protected void SqlDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["@OrderID"].Value = OrderID;
}
Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang (, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.