Here is how you should be able to do it:
1. Remove the
SqlDataSource
from the User control, and, keep only the FormView. For example:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UcDetails.ascx.cs" Inherits="UcDetails" %>
<asp:FormView ID="FormView1" runat="server">
</asp:FormView>
2. Create a
SqlDataSource
parameter inside the User control's code behind and assign FormView's
DataSourceID
in the Page_Load(). For example:
public SqlDataSource DataSource
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e)
{
FormView1.DataSourceID = DataSource.ID;
}
3. Put the
SqlDataSource
in the Aspx pages. For example:
<body>
<form id="form1" runat="server">
<uc1:UcDetails ID="UcDetails1" runat="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
</form>
</body
>
4. Set the
DataSource
of the
FormView
into the
Page_Load()
of aspx pages. For example:
protected void Page_Load(object sender, EventArgs e)
{
UcDetails1.DataSource = SqlDataSource1;
}
I think you should get the basic idea and can implement your functionality.