我用DATALIST 控件的时候放入其中一个自定义的用户控件当页面第一次加载的时候 用户控件可以接收到值第二次就不行了
控件代码:
private string zxlyid;
public string lyid
{
set
{
               this.zxlyid=value.ToString();
}
}
  private void Page_Load(object sender, System.EventArgs e)
{
// if (!this.Page.IsPostBack)
{
System.Data.SqlClient.SqlConnection con=db.dbcon();
con.Open();
System.Data.SqlClient.SqlDataAdapter sda=new System.Data.SqlClient.SqlDataAdapter();
sda.SelectCommand=new System.Data.SqlClient.SqlCommand (" select * from zxly where lyid="+this.zxlyid,con);
DataSet ds=new DataSet();
sda.Fill(ds,"emp");
this.lbname.Text=ds.Tables["emp"].Rows[0][1].ToString();
this.laemail.Text=ds.Tables["emp"].Rows[0][2].ToString();
this.lboicq.Text=ds.Tables["emp"].Rows[0][3].ToString();
this.lbtel.Text=ds.Tables["emp"].Rows[0][7].ToString();
this.lbhttp.Text=ds.Tables["emp"].Rows[0][11].ToString();
im.ImageUrl=Server.MapPath("cptp")+"\\"+ds.Tables["emp"].Rows[0][4].ToString();
this.lbfbrq.Text=ds.Tables["emp"].Rows[0][5].ToString();
this.lbfbnr.Text=ds.Tables["emp"].Rows[0][6].ToString();
this.lbhfnr.Text=ds.Tables["emp"].Rows[0][8].ToString();
this.lbhfrq.Text=ds.Tables["emp"].Rows[0][10].ToString();
con.Close();
}// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
代码:
/// </summary>
public class GXCPLT : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox tname;
protected System.Web.UI.WebControls.TextBox temail;
protected System.Web.UI.WebControls.TextBox toicq;
protected System.Web.UI.WebControls.TextBox ttel;
protected System.Web.UI.WebControls.TextBox thttp;
protected System.Web.UI.WebControls.TextBox tlynr;
protected System.Web.UI.WebControls.RadioButton r1;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Image Image2;
protected System.Web.UI.WebControls.RadioButton r2;
protected System.Web.UI.WebControls.Image Image3;
protected System.Web.UI.WebControls.RadioButton r3;
protected System.Web.UI.WebControls.Image Image4;
protected System.Web.UI.WebControls.RadioButton r4;
protected System.Web.UI.WebControls.Image Image5;
protected System.Web.UI.WebControls.RadioButton r5;
protected System.Web.UI.WebControls.Image Image6;
protected System.Web.UI.WebControls.RadioButton r6;
protected System.Web.UI.WebControls.RadioButton r7;
protected System.Web.UI.WebControls.Image Image7;
protected System.Web.UI.WebControls.RadioButton r8;
protected System.Web.UI.WebControls.Image Image8;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.DataList DataList1;

private void Page_Load(object sender, System.EventArgs e)
{
if (!this.Page.IsPostBack)
{
            this.Label2.Text="1";
this.databind();
}// 在此处放置用户代码以初始化页面
} private void databind()
{   int dqy=Convert.ToInt32(this.Label2.Text);
System.Data.SqlClient.SqlConnection con=db.dbcon();
con.Open();
System.Data.SqlClient.SqlDataAdapter sda =new System.Data.SqlClient.SqlDataAdapter ();
sda.SelectCommand=new System.Data.SqlClient.SqlCommand (" select * from zxly order by lyid desc",con);
DataSet ds=new DataSet();
sda.Fill(ds,"zxly");
System.Web.UI.WebControls.PagedDataSource ps=new PagedDataSource();
ps.DataSource=ds.Tables["zxly"].DefaultView;
ps.AllowPaging=true;
ps.PageSize=4;
ps.CurrentPageIndex=dqy-1;
this.Label4.Text=Convert.ToString(ps.PageCount);
this.Button2.Enabled=true;
this.Button3.Enabled=true;
if (dqy==1)
{
this.Button2.Enabled=false;
}
if (dqy==ps.PageCount)
{
this.Button3.Enabled=false;
} DataList1.DataSource=ps;
DataList1.DataBind();
ds.Clear();
con.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string sql;
sql="insert into zxly (name,email,oicq,gif,lysj,lynr,lydh,grzy,hfnr,hfrq) values  ('"+this.tname.Text+"','"+this.temail.Text+"','"+this.toicq.Text+"',";
if (r1.Checked)
{
             sql+="  '1.gif',";
}
if (r2.Checked)
{
sql+="  '2.gif',";
}
if (r3.Checked)
{
sql+="  '3.gif',";
}
if (r4.Checked)
{
sql+="  '4.gif',";
}
if (r5.Checked)
{
sql+="  '5.gif',";
}
if (r6.Checked)
{
sql+="  '6.gif',";
}
if (r7.Checked)
{
sql+="  '7.gif',";
}
if (r8.Checked)
{
sql+="  '8.gif',";
}
sql+=" '"+System.DateTime.Now.ToString().Substring(0,9)+"','"+this.tlynr.Text+"','"+this.ttel.Text+"','"+this.thttp.Text+"','无','"+System.DateTime.Now.ToString().Substring(0,9)+"') ";
System.Data.SqlClient.SqlConnection con=db.dbcon();
con.Open();
System.Data.SqlClient.SqlCommand cmd=new System.Data.SqlClient.SqlCommand(sql,con);
cmd.ExecuteNonQuery();
// Response.Redirect("GXCPLT.aspx");
this.databind();
con.Close(); } private void Button2_Click(object sender, System.EventArgs e)
{
this.Label2.Text=Convert.ToString ((Convert.ToInt32(this.Label2.Text)-1));
// Response.Redirect("GXCPLT.aspx");
this.databind();
} private void Button3_Click(object sender, System.EventArgs e)
{
this.Label2.Text=Convert.ToString ((Convert.ToInt32(this.Label2.Text)+1));
this.databind();
}
}
后期绑定
<TR>
<TD style="HEIGHT: 3px" vAlign="top" align="left">
<asp:DataList id="DataList1" runat="server" Width="100%" Height="100%" RepeatColumns="1">
<ItemTemplate>
<uc1:zxly id=Zxly1 runat="server" 
lyid='<%# DataBinder.Eval(Container.DataItem,"lyid")%>'>
</uc1:zxly>
</ItemTemplate>
<AlternatingItemTemplate>
<uc1:zxly id=Zxly2 runat="server"
 lyid='<%# DataBinder.Eval(Container.DataItem,"lyid")%>'>
</uc1:zxly>
</AlternatingItemTemplate>
</asp:DataList></TD>
</TR>