日期:2014-05-19  浏览次数:20487 次

repeater问题
aspx:
<form   method= "post "   runat= "server "   ID= "form1 ">  
<table   width= '85% '   border= '0 '   cellspacing= '0 '   cellpadding= '0 '>
<tr>
<td   height= '24 '   align= 'right '     colspan=3> <font   color= "#426402 ">
<asp:HyperLink   ID= "newlink "   runat= "server "   NavigateUrl= "app.aspx "   Target= "_self "   Text= "新建 "   ToolTip= "新建申请品种信息 "> </asp:HyperLink>  
                        &nbsp;|&nbsp;   <asp:LinkButton   ID= "delLink "   Text= "删除 "   runat= "server "> </asp:LinkButton> </font>
</td>
<asp:repeater   id= "vList "   enableviewstate= "False "   runat= "server ">
<headertemplate>                        
</tr>
<tr     bgcolor= "#B1EFBB ">
<td   width= "5% "> <input   type= "CheckBox "   id= "chk "   onclick= "checkall(this); ">
</td>
<td> &nbsp;编号 </td>
<td> &nbsp;暂定名称 </td>
<td> &nbsp;申请日期 </td>
</tr>
</headertemplate>
<itemtemplate>
<tr>
<td> <asp:CheckBox   id= "sel "   runat= "server "> </asp:CheckBox> </td>
<td> <a   href= "vcenter.aspx?no= <%#   DataBinder.Eval(Container.DataItem,   "appno ")%> "   target= "_self "> <%#   DataBinder.Eval(Container.DataItem,   "appno ")%> </a> </td>
<td> <%#   DataBinder.Eval(Container.DataItem,   "vname ")%> </td>
<td> <%#   DataBinder.Eval(Container.DataItem,   "appdate ")%> </td>
</tr>
</itemtemplate>
<footertemplate>
</footertemplate>  
</asp:repeater>
</table>
<asp:Label   Text= " <br> ok <br> ! "   id= "Err_message "     style= "color:Red; "   visible=false   runat= "server "/>
</form>

cs中:
protected   void   Page_Load(object   sender,   EventArgs   e)
{
dbHandle=new   CAdoHandle(this);
if(!IsPostBack)
{
BindPagedData();
for(int   i=0;i <vList.Items.Count;i++)
{
CheckBox   chk=(CheckBox)vList.Items[i].FindControl( "sel ");
chk.Attributes.Add( "onclick ", "uncheck(this); ");
}
}
}

protected   void   delLink_Click(object   sender,EventArgs   e)
{
string   msg=null;
msg=vList.Items.Count.ToString();
for(int   i=0;i <vList.Items.Count;i++)
{
CheckBox   chk=(CheckBox)vList.Items[i].FindControl( "sel ");
if(chk.Checked==true)
{
string   appno=((DataBoundLiteralControl)vList.Items[i].Controls[1]).Text;
if(msg== " ")
msg=appno;
else
msg=msg+ "; "+appno;
}
}
Err_message.Text= " <br> <br> aoono: "+msg+ " <br> ";