日期:2014-05-18  浏览次数:20389 次

repeater嵌套的repeater中的linkbutton怎么触发事件??
前台代码
<div class="area-list">
  <ul class="menu">
  <asp:Repeater ID="Repeater1" runat="server" 
  onitemdatabound="Repeater1_ItemDataBound">
  <ItemTemplate>
  <li>
   
  <a href="#"><%#Eval("FoodType") %></a>
  <ul class="menu-in">
  <asp:Repeater ID="Repeater2" runat="server">
  <ItemTemplate>
  <li> 
  <asp:LinkButton ID="FoodtypeID" runat="server"><%#Eval("FoodType") %></asp:LinkButton>
  <!--<a id="<%#Eval("FoodTypeID") %>" href="javascript: void(0);" onclick="dd('<%#Eval("FoodTypeID") %>')"><%#Eval("FoodType") %></a>-->
  </li>
  </ItemTemplate>
  </asp:Repeater>
  </ul>
  </li>
  </ItemTemplate>
  </asp:Repeater>
  </ul>
   
  </div>
后台
 protected void Page_Load(object sender, EventArgs e)
  {
   
  if (!IsPostBack)
  {
  BindGrid();
   
  }
  }

  private void BindGrid()
  {
  string connString = ConfigurationManager.ConnectionStrings["sqlconnectionstring"].ConnectionString;
  SqlConnection conn = new SqlConnection(connString);
   
  string sql = "Select * From tb_FoodType where FoodTypeUp=0";
  SqlDataAdapter da = new SqlDataAdapter(sql, conn);
  DataSet ds = new DataSet();
  da.Fill(ds, "Table1");

  DataTable dt = ds.Tables["Table1"];
  Repeater1.DataSource = ds;
  Repeater1.DataBind();

  }
   
  protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
  {
  if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  {
  Repeater rep = e.Item.FindControl("Repeater2") as Repeater;
  DataRowView rowv = (DataRowView)e.Item.DataItem;
  int typeid = Convert.ToInt32(rowv["FoodTypeID"]);
  string sql2 = "select * from tb_FoodType where FoodTypeUp='" + typeid + "'";
  DataSet ds2 = GetDs(sql2, "Table1");
  rep.DataSource = ds2.Tables["Table1"];
  rep.DataBind();
  }
  }
   
  public DataSet GetDs(string sql, string table)
  {
  string connString = ConfigurationManager.ConnectionStrings["sqlconnectionstring"].ConnectionString;
  SqlConnection conn =