<asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Timer ID="Timer1" runat="server" Interval="10000"> </asp:Timer> </div> <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"><Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> <ContentTemplate> <asp:DataGrid ID="grvDemo" runat="server" Width="100%" GridLines="Both" HeaderStyle-BackColor="AntiqueWhite" AutoGenerateColumns="true"> </asp:DataGrid> </ContentTemplate> </asp:UpdatePanel>
using System.Data;using System.Data.SqlClient; protected void Page_Load(object sender, EventArgs e) { BindGrid(); } public void BindGrid() { //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString); SqlConnection con = new SqlConnection("Data Source=BITPLUS5\\SqlExpress;Initial Catalog=temp;User ID=sa;pwd=bit123;"); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from chat order by 1"; cmd.Connection = con; con.Open(); SqlDataReader dr = cmd.ExecuteReader(); grvDemo.DataSource = dr; grvDemo.DataBind(); }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: