I have one ASPX page and inside that one user control and that user control contains one grid to display the data, the data will load into grid view using DatasourceID and one sqldatasource control.
now my question is that when i add one record in that table that record is not shown in my grid, but when i refresh the page or reload the page at that time that record is displayed in grid.
so how to refresh the grid while we use a sqldatasource control.
<asp:TextBox ID="txtName" runat="server">
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
code behind is like this.
protected void btnSave_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString.ToString());
SqlDataAdapter da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand();
da.InsertCommand.Connection = con;
da.InsertCommand.CommandType = CommandType.Text;
da.InsertCommand.CommandText = "INSERT INTO [User] ([NAME]) VALUES (@NAME)";
i have configured my sqldata source like this.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConStr %>"
SelectCommand="SELECT * FROM [User]">
and my grid view is like this.
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
In short... I want to refresh my grid when i insert the record to my grid.
I am using Oracle as my database.