aspx页面中动态创建控件 (转)

aspx页面中动态创建控件 (转)[@more@]

<Mailto:%@page" rel="nofollow">%@page language="C#"%>
<%@import namespace="System.Data"%>
<%@import namespace="System.Data.Oledb"%>
<%@import namespace="System.Text"%>


 Hashtable hashProductName = new Hashtable();
 Hashtable hashProductDesc = new Hashtable();

public void page_load(object obj,EventArgs e)
{

 hashProductName[0] = "Jalapeno Dip" ;
 hashProductName[1] = "Smoked Sausage" ;
 hashProductName[2] = "Shrimp Fiesta" ;
 hashProductName[3] = "Jerk Chicken" ;
 hashProductName[4] = "Beer-Battered Fish" ;
 hashProductName[5] = "Bacon Burger" ;
 hashProductName[6] = "Sirloin Tip" ;
 hashProductName[7] = "Baked Alaska" ;
 hashProductName[8] = "Fried Chicken" ;
 hashProductName[9] = "Fresh Garden Salad" ;
 hashProductName[10] = "One Pea" ;

 hashProductDesc[0] = "Simmered in mayonaise and wine, this Jalapeno Dip will make your eyes water" ;
 hashProductDesc[1] = "Mouth watering and delicious sausage" ;
 hashProductDesc[2] = "East Coast's finest shrimp" ;
 hashProductDesc[3] = "A real island experience you will not forget" ;
 hashProductDesc[4] = "Pabst Blue Ribbon and Fish. Wow!" ;
 hashProductDesc[5] = "Big, juicy, and bursting with flavor" ;
 hashProductDesc[6] = "Delicate cuts with no fat" ;
 hashProductDesc[7] = "Fine dessert comprised of sponge cake topped with ice cream and covered with meringue. " ;
 hashProductDesc[8] = "Country cookin'" ;
 hashProductDesc[9] = "Crispy iceberg lettuce and a garden of vegtables" ;
 hashProductDesc[10] = "A single green pea that will leave you craving more" ;

 for (int i=0; i<=10; i++)
 {
  LinkButton LB5= new LinkButton();
  LB5.Text = hashProductName[i].ToString();
  LB5.CommandName = "Products";
  LB5.CssClass = "ProductLinks";
  LB5.CommandArgument = i.ToString() ;
  LB5.Command += new System.web.UI.WebControls.CommandEventHandler(OnLinkClick);
  LinkList.Controls.Add(LB5);
  LinkList.Controls.Add(new LiteralControl("
"));
 }
}

private void OnLinkClick(object O, System.Web.UI.WebControls.CommandEventArgs E)
{
 int RecordId = Int32.Parse(E.CommandArgument.ToString());
 tablecellMessage.Text=""+hashProductName[RecordId].ToString()+"
"+hashProductDesc[RecordId].ToString()+"";
}

RM runat="server">

<ASP:Table CellPadding=6 CellSpacing=2 BorderColor="#DDDDDD" BorderStyle=Solid BorderWidth=2 Runat=server>

 
 



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-993465/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-993465/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值