如果数据源为空,如何在手风琴中显示自定义消息 [英] How to display custom message in accordian if datasource is null

查看:71
本文介绍了如果数据源为空,如何在手风琴中显示自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用嵌套的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.

推荐答案

我按如下所示工作了.

I got it working as shown below .

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


Hi,

在绑定您的数据控件时,只需将文本设置在第一个手风琴控件中即可.

使用pageload方法从后端绑定数据控件.

首先检查获取的数据是否为空.如果在第一手风琴面板中设置为空,则

我希望你能理解我说的话



最好的
Hi,

At the time of binding uour data control just set the text in first accordian control.

Bind your datacontrol from back end in pageload method .

First check fetched data is empty or not.If empty set text in first accordian panel

I hope you understood what I said



All the Best


这篇关于如果数据源为空,如何在手风琴中显示自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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