Search code examples
c#asp.netdata-bindingdata-transfer

How to pass a variable from .cs to .aspx


As the title suggests, I want to add something to a table (inside aspx page) depending on some infos I get from a database (so if I have an item x in db I will make a bool type variable in cs).

My question is, is there any method to send that bool to aspx so I can use it inside an if statement (in order to add the respective columns to my table).


Solution

  • You don't need a session variable here, you can simply declare a class level property and use it in your ASPX page:-

    public bool variable { get; set; }
    

    and then directly use it in your aspx page:-

    <%=variable %>