Converting value of an Eval from int to string

后端 未结 3 977
广开言路
广开言路 2021-01-12 21:40

I have an integer stored in my database that I need to convert string.

This is my attempt at the Eval:

<%# ChangeSalaryType(Eval(\"SalaryType\"))          


        
3条回答
  •  庸人自扰
    2021-01-12 22:26

    I prefer to send the DataItem on code behind, and there get the data as:

    <%#RenderSalaryType(Container.DataItem)%>
    

    and on code behind

    protected string RenderSalaryType(object oItem)
    {
        int salaryType = (int)DataBinder.Eval(oItem, "SalaryType");
    
        // rest of your code
    }
    

提交回复
热议问题