“找到的记录数量” datalist标题部分中的标签 [英] "Number of records found " label in datalist header part

查看:98
本文介绍了“找到的记录数量” datalist标题部分中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我想显示在datalist标题部分找到的记录数。

请任何人建议我,怎么做?

解决方案

在datalist的标题模板中添加标签。



将数据绑定到datalist时使用datalist控件的方法findcontrol并按ID查找标签并创建其对象并赋值。







 lable lblCount =(lable)datalist.findcontrol(  lblid); 
if (lblCount!= null
{
lblCount。 text = yourdatatable.row.count.tostring();
}


在堆栈跟踪中找到...

谢谢..

 protected void dlMembers_ItemDataBound(object sender,DataListItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Header)
{
Literal lblCat =(Literal )e.Item.FindControl( ltrlDoctors);
lblCat.Text =Found+ dsFindMembers.Tables [0] .Rows.Count.ToString()+您的搜索条件中的医生。;
}
if(e.Item.ItemType == ListItemType.Footer)
{
Label lblFoot =(Label)e.Item.FindControl(lblFooter);
lblFoot.Text =已更改;


}
}


或者,试试



 <   HeaderTemplate  >  
< asp:Label 文字 =' <%#DataList1.Items.Count %> ' runat = server ID = lblTotal > < / asp:标签 >
< / headerTemplate >


Hi Friends,
I want to display the number of records found in the datalist's header part.
Please any one suggest me, how to do that?

解决方案

add lable in the header template of datalist.

when you bind data to datalist use a method findcontrol of datalist control and find the lable by ID and create its object and assign value.



lable lblCount = (lable) datalist.findcontrol("lblid");
if(lblCount !=null)
{
lblCount .text = yourdatatable.row.count.tostring();
}


Found in stacktrace...
Thanks..

protected void dlMembers_ItemDataBound(object sender, DataListItemEventArgs e)
   {
       if (e.Item.ItemType == ListItemType.Header)
       {
           Literal lblCat = (Literal)e.Item.FindControl("ltrlDoctors");
           lblCat.Text = "Found "+dsFindMembers.Tables[0].Rows.Count.ToString() +" doctor(s) from your search criteria. ";
       }
       if (e.Item.ItemType == ListItemType.Footer)
       {
           Label lblFoot = (Label)e.Item.FindControl("lblFooter");
           lblFoot.Text = "Changed";


       }
   }


Alternatively , Try

<HeaderTemplate>
<asp:Label Text='<%#DataList1.Items.Count%>' runat="server" ID="lblTotal" ></asp:Label>
</headerTemplate>


这篇关于“找到的记录数量” datalist标题部分中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆