c# - how to dynamically fill Bootstrap dropdown -
c# - how to dynamically fill Bootstrap dropdown -
i new bootstrap.i have notification drop downwards fills
<!-- begin notification dropdown --> <li class="dropdown" id="notifications-header"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <i class="glyph-icon flaticon-notifications"></i> <span class="badge badge-danger badge-header">6</span> </a> <ul class="dropdown-menu"> <li class="dropdown-header clearfix"> <p class="pull-left">notifications</p> </li> <li> <ul class="dropdown-menu-list withscroll" data-height="220"> <li> <a href="#"> <i class="fa fa-star p-r-10 f-18 c-orange"></i> steve have rated photo <span class="dropdown-time">just now</span> </a> </li> <li> <a href="#"> <i class="fa fa-heart p-r-10 f-18 c-red"></i> john added favs <span class="dropdown-time">15 mins</span> </a> </li>
and on how can dynamically populate dropdown database?
here answer...i putting mechanism of how works...anybody can utilize info construction suites them.
(1)in database created simple table called "notifications" 3 fields (a)friend_name ; store name of friends message (b)notifications; store original message (3)notification_time; store time @ 1 messaged you
(2) in code behind created 3 lists object , integer filed store message count
(a)friend_name ; store name of friends message (b)notifications; store original message (c)notification_time; store time @ 1 messaged (d)count ; store message count. private list friend_name = new list(); private list notification_time = new list(); private list notification_time = new list();
(3)now populate these lists in page load usual developer... conn = new sqlconnection("data source=xxxx;initial catalog=xxxx;integrated security=true"); sqlcommand comm = new sqlcommand("select * notifications"); comm.connection = conn; comm.commandtype = commandtype.text; sqldatareader reader; conn.open(); reader = comm.executereader();
while (reader.read()) { friend_name.add(reader["friend_name"].tostring()); notifications.add(reader["notifications"].tostring()); notification_time.add(reader["notification_time"].tostring()); count++; }
(4)now go aspx file (markup) , phone call 3 lists object that... <% (int i=0; '<%=friend_name[i]%>' '<%=notification_time[i]%>'
'<%=notifications[i]%>'...
<% } %>
finally able fill bootstrap dynamically.
c# database twitter-bootstrap
Comments
Post a Comment