c# - Passing reader object from aspx.cs file to View (.aspx) -


this not duplicate of other question. if there similar , didn't worked me. have searched lot unable solve issue. kindly guide me.

i have made query database records in aspx.cs file. records in reader object. want access object in view file (.aspx file). here small part of code.

in .aspx.cs file

string qry = "select *  `enduser`  `firstname`  @key limit 0 , 30"; cmd = new mysql.data.mysqlclient.mysqlcommand(qry, connection.getconnection().open()); cmd.parameters.addwithvalue("@key", keyword); mysqldatareader reader = cmd.executereader(); 

in .aspx file

can tell me how access here in aspx file.

1- have tried sessions not worked.
2- have tried other way <% =myvariable; %>   // not worked

i want reader object in view file , iterate displat each record. thanks

you should use 1 of controls available in asp .net, example repeater. need bind repeater datasource. rest done automatically.

see example here:

http://www.tutorialspoint.com/asp.net/asp.net_data_binding.htm

repeater example:

http://www.w3schools.com/aspnet/aspnet_repeater.asp

the databinding expressions (your point 2) work in context of databound control.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -