0

How do I get the value in my code behind. So, that I can use it on my aspx page? I tried:

private int lastval;
public int LastVal { get { return lastval; } }

Then I will use it in gridview like this:`

 SelectCommand="SELECT * FROM [Order] where OrderId='<%=LastVal %>'"

But, it doesn't get the data.

Chirag
  • 994
  • 2
  • 11
  • 26
SALO
  • 1
  • 3
  • Define "doesn't get the data". Errors? Wrong values? Something else? – Sami Kuhmonen May 27 '17 at 10:32
  • it doesn't get the value of lastval in code behind that's why I can't use it for select statement of gridview in aspx page @SamiKuhmonen – SALO May 27 '17 at 10:45
  • Possible duplicate of [How to pass variable to SelectCommand of SqlDataSource?](https://stackoverflow.com/questions/485821/how-to-pass-variable-to-selectcommand-of-sqldatasource) – hardkoded May 27 '17 at 13:52
  • @SALOI posted a link for you to check. The problem is that Code Blocks (`<$= %>`) are executed too late in the pipeline, in the Page Render method, after your grid is bound. – hardkoded May 27 '17 at 13:53

0 Answers0