c# - Using Sql data after binding to repeater -


i wish use data database after binding query repeater. i'm not sure how supposted this. here code:

sqlconnection conn = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].tostring()); sqlcommand cmd = new sqlcommand("select * kontakt", conn);  conn.open(); sqldatareader reader = cmd.executereader(); repeater_beskeder.datasource = reader; repeater_beskeder.databind();      foreach (repeateritem row in repeater_beskeder.items)     {         if (reader.read())         {             panel vis_panel = (panel)row.findcontrol("panel_vis_besked");             if (request.querystring["id"].tostring() == reader["id"])             {                 vis_panel.visible = true;             }         }     } conn.close(); 

my reader wont work it's allready been binded repeater, i'm quite lost. hope of have solution problem.

itemdatabound event occurs after item in repeater control data-bound before rendered on page.

 void repeater_beskeder_itemdatabound(object sender, repeateritemeventargs e) {        // event raised header, footer, separators, , items.        // execute following logic items , alternating items.       if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) {          panel vis_panel = (panel)row.findcontrol("panel_vis_besked");         if (request.querystring["id"].tostring() == reader["id"])         {             vis_panel.visible = true;         }       }    }     

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -