Hello,
I am trying to display a dataset to my ASP.NET application. It seems that when I click the button event, the data is not displaying in the grid.
I have a basic page with the following:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" Width="200" Height="300">
</asp:GridView>
<asp:Button runat="server" id="UpdateButton1" onclick="UpdateButton_Click" text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
Then in the code behind, I have the following:
protected void UpdateButton_Click(object sender, EventArgs e)
{
string SQLConfigSettings = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(SQLConfigSettings);
sqlconn.Open();
SqlDataAdapter adapter = new SqlDataAdapter("Select * from Student", sqlconn);
DataSet ds = new DataSet();
adapter.Fill(ds);
GridView1.DataSource = ds;
UpdatePanel.Update();
}
Am I missing something? Shoudlnt the dataset be diaplayed in the grid? When I click the button nothing happens.
Thanks :)