问题描述
我正在使用嵌套的ajax手风琴控件.
即第一个Accordian控件和第二个Accordian控件以及第二个内部有gridview.
如果第二手风琴控制(位于第一手风琴控件内部)的数据源为空,如何显示诸如未找到记录"之类的自定义消息.
是否像在gridview控件中一样,在Accordian中有像Emptydatatext这样的属性.
Hi,
I am using a nested ajax accordian control.
i.e First accordian controls and inside that the second accordian control and inside the second one there is a gridview.
How can i display a custom message like "no records found" if the datasource to second accordian contol(which is inside first accordian control) is null.
Is there any property like emptydatatext in the accordian as we have in gridview control.
推荐答案
AjaxControlToolkit.Accordion grd = new AjaxControlToolkit.Accordion();
grd = (AjaxControlToolkit.Accordion)e.AccordionItem.FindControl("Accordion2");
TemplateBuilder head = new TemplateBuilder();
TemplateBuilder content = new TemplateBuilder();
if (myDataset.Tables[0].Rows.Count > 0)
{
grd.DataSource = myDataset.Tables[0].DefaultView;
grd.DataBind();
}
else
{
//head.AllowWhitespaceLiterals();
//head.AppendLiteralString("Sorry no records Found!!!");
content.AllowWhitespaceLiterals();
content.AppendLiteralString("<b>Sorry no records Found!!!</b>");
//Create the Pane and set the head and content to your templatebuilders
AjaxControlToolkit.AccordionPane test = new AjaxControlToolkit.AccordionPane();
test.ID = "test";
// test.Header = head;
test.Content = content;
//Add Pane To Accordion
grd.Panes.Add(test);
}
//Accordion2.DataSource = myDataset.Tables[0].DefaultView;
//Accordion2.DataBind();
}
使用模板构建器来创建一个新模板,其默认内容文本设置为未找到记录".然后将此模板应用于动态创建的Accordian窗格,然后将此窗格添加到页面中显示的Accordian
used template builder to create a new template with default content text set to "No records found". then applying this template to an dynamically created accordian pane and then adding this pane to the accordian present in the page
这篇关于如果数据源为空,如何在手风琴中显示自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!