Converting value of an Eval from int to string

后端 未结 3 988
广开言路
广开言路 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:04

    Even though you know that the SalaryType field will be an int in your aspx it will be cast as object after the Eval(). Do an explicit cast like so:

    <%# ChangeSalaryType(Convert.ToInt32(Eval("SalaryType"))) %>
    

提交回复
热议问题