Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在repeater asp.net中调用函数_Asp.net_Repeater - Fatal编程技术网

在repeater asp.net中调用函数

在repeater asp.net中调用函数,asp.net,repeater,Asp.net,Repeater,我想调用一个函数将数据绑定到中继器。是否需要设置此控件或Repeater的dataSource属性。DataBind()将起作用 <asp:Repeater ID="RepeaterDays" runat="server"> <ItemTemplate> <ul> <asp:Label ID="lblDays" runat="server" Text='<%#ChandanIdiot()%>'&

我想调用一个函数将数据绑定到中继器。是否需要设置此控件或Repeater的dataSource属性。DataBind()将起作用

<asp:Repeater ID="RepeaterDays" runat="server">
    <ItemTemplate>
        <ul>
            <asp:Label ID="lblDays" runat="server" Text='<%#ChandanIdiot()%>'></asp:Label>
        </ul>
    </ItemTemplate>
</asp:Repeater>

我已经编写了RepeaterDays.Databind(),但是没有调用该函数

这没有显示任何内容。

ChandanIdiot()是返回字符串的受保护函数吗

    protected string ChandanIdiot() {
        return "test";
    }
如果要实际执行某些数据处理,必须包含一个参数:

    protected string ChandanIdiot(object obj) {
        return "test " + obj;
    }
并且,假设您正在重新复制的对象上有一个名为“Name”的属性,您将有以下内容:

<asp:Label ID="lblDays" runat="server" Text='<%# ChandanIdiot(Eval("Name")) %>' />

来源:

C#:
受保护字符串ChandanIdiot(对象ob){
字符串类型=ob.ToString();//存储在ob中的选定值
如果(类型=“某些函数”){
//干坏事
}
return-typ;//返回到的值
}
<asp:TemplateField HeaderText="Unit Price">
    <ItemTemplate>
        <%# ChandanIdiot( Eval("product_unitprice"))%>
        <!--product_unitprice is table colomn name -->
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="TextBox4" runat="server" ></asp:TextBox>
    </EditItemTemplate>
</asp:TemplateField>
protected string ChandanIdiot(object ob) {
    string typ = ob.ToString(); //selected value stored in ob
    if (typ == "some function") {
        //do somthing 
    }
    
    return typ ; //value return to <%# ChandanIdiot( Eval("product_unitprice"))%>
}