注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

我只是一个人

我爱一个人

 
 
 

日志

 
 

Repeater的操作  

2011-05-17 12:54:12|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

显示数据

 <asp:Repeater ID="rptMessageCompany" runat="server" onitemcommand="rptMessageCompany_ItemCommand">
            <ItemTemplate>
                <tr>
                  <td width="5%">
                    <asp:CheckBox ID="ck" runat="server" />
                    <asp:HiddenField ID="hfId" runat="server" Value='<%#Eval("i_id") %>' />
                  </td>
                  <td width="5%"><%#Eval("i_id") %></td>
                  <td width="12%"><%#Eval("d_time")%></td>
                  <td width="12%"><%#Eval("s_agentname")%><br /><%#Eval("s_address")%></td>
                  <td width="19%"><%#Message.GetMessageComOrProName(Eval("i_pocid").ToString(), Eval("i_Ispoc").ToString())%></td>
                  <td width="10%"><%#Eval("s_areatype")%></td>
                  <td width="19%"><%#Eval("s_address")%><br /><%#Eval("s_content")%></td>
                  <td width="13%"><%#Eval("s_ip")%></td>
                  <td width="5%"><asp:LinkButton ID="lkbtnDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="删除" CommandArgument='<%# Eval("i_id") %>' OnClientClick="return confirm('您确定要删除吗?');"></asp:LinkButton></td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>

显示隐藏子控件,遍历Repeater ,查找每行

 if (e.CommandName=="Remark")//查找备注按钮并执行相应操作
        {
            TextBox tb = (TextBox)e.Item.FindControl("TextBox1");
            LinkButton lbtn = (LinkButton)e.Item.FindControl("Remark");//备注按钮
            LinkButton lbtn2 = (LinkButton)e.Item.FindControl("ok");//确认按钮
            LinkButton close = (LinkButton)e.Item.FindControl("close");//取消按钮
            LinkButton del = (LinkButton)e.Item.FindControl("lkbtnDel");
            foreach(RepeaterItem ar in Repeater1.Items)
            {

                TextBox tbs = (TextBox)ar.FindControl("TextBox1");
                LinkButton lbtns = (LinkButton)ar.FindControl("Remark");//备注按钮
                LinkButton lbtn2s = (LinkButton)ar.FindControl("ok");//确认按钮
                LinkButton closes = (LinkButton)ar.FindControl("close");//取消按钮
                LinkButton dels = (LinkButton)ar.FindControl("lkbtnDel");
                if (tbs.Visible = true)
                {
                    tbs.Visible = false;
                    lbtns.Visible = true;
                    lbtn2s.Visible = false;
                    closes.Visible = false;
                    dels.Visible = true;
                }
            }
            del.Visible = false;
            tb.Visible = true;
            close.Visible = true;
            tb.MaxLength = 100;
            //=====================================
            //实例化DB类,创建对象,并调用sql语句返回 dr
            DB dbsql=new DB();
            string sqlstring = "select Remark from tab_company where i_id=" + Convert.ToInt16(e.CommandArgument);
            SqlDataReader dr=dbsql.getdr(sqlstring);
            if (dr.Read())
            {
                tb.Text = dr["Remark"].ToString();
                dr.Close();
            }
          
            lbtn.Visible = false;
            lbtn2.Visible = true;
            lbtn2.ForeColor = System.Drawing.Color.Blue;

        }

 

绑定数据

   Repeater1.DataSource = DB.GetPager(1, 20, "i_id,s_name,s_oname,s_user,d_time,i_check,i_isVIP,s_kfname,s_areatypeId,Remark", "tab_company", hidd_where.Value, hidd_searchwhere.Value, "order by i_id desc", "i_id ");
  Repeater1.DataBind();

分页控件的使用

             this.AspNetPager1.RecordCount = DB.GetDataSetCount("count(i_id)", "tab_message", wherecount, "");
        this.AspNetPager1.EnableUrlRewriting = true;
        this.AspNetPager1.UrlRewritePattern = "/jingxiaoshang/" + Common.NoHTML(Request.QueryString["area"]) + "_" + page + "{0}";
        this.rptDaili.DataSource = DB.GetPager(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, "i_id,i_pocid,s_title,s_tel,n_tel,s_content,d_time,s_agentname,s_areatype,s_address,i_Ispoc,i_isdel,s_ip,s_areatypeoname", "tab_message", where, searchwhere, "order by d_time desc", "i_id ");
        this.rptDaili.DataBind();

        lblCurrentPage.Text = this.AspNetPager1.CurrentPageIndex.ToString();
        lblPageCount.Text = this.AspNetPager1.PageCount.ToString();
        lblTotal.Text = this.AspNetPager1.RecordCount.ToString();

  评论这张
 
阅读(117)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018