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
Post a Comment