Gridview Not updating in Update Panel
Posted on
16th Feb 2014 07:03 pm by
admin
I have a gridview, three dropdown list boxes, and a button on my form. What is displayed in the gridview depends on the values entered in the dropdown list boxes. The button calls a stored procedure that inserts a record into the table behind the gridview. I have an AsyncPostBack set up on the button click, but the gridview will not update when the button is clicked. I've tried moving the button into the update panel and also moving the three dropdown list boxes into the update panel, but it still doesn't work. One concern with having the three dropdown list boxes in the update panel is that I don't want them to refresh on the button click. I need them to remain at the same values they were at when the button was clicked. Does anyone know what I'm missing here? Thanks.
VB Codeview plaincopy to clipboardprint?Imports System.Data.SqlClient Imports Microsoft.SqlServer.Server Imports System.Configuration Partial Class IG_Maintain Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New SqlConnection() Dim cmd As New SqlCommand() 'getting connection string from Web.config conn.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString2").ConnectionString cmd.Connection = conn 'stored procedure for data insert cmd.CommandText = "insert_goal" cmd.CommandType = Data.CommandType.StoredProcedure 'Pass parameters required by the stored procedure cmd.Parameters.AddWithValue("@unitdd", DropDownList3.Text) cmd.Parameters.AddWithValue("@yeardd", DropDownList1.Text) cmd.Parameters.AddWithValue("@ignumdd", DropDownList2.Text) Dim errorcode As Integer = 0 Try conn.Open() cmd.ExecuteNonQuery() Catch ex As Exception errorcode = 1 Response.Write(ex) Finally conn.Close() End Try If errorcode = 0 Then 'Response.Redirect("IG_Maintain.aspx") End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub End Class Imports System.Data.SqlClientImports Microsoft.SqlServer.ServerImports System.ConfigurationPartial Class IG_Maintain Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New SqlConnection() Dim cmd As New SqlCommand() 'getting connection string from Web.config conn.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString2").ConnectionString cmd.Connection = conn 'stored procedure for data insert cmd.CommandText = "insert_goal" cmd.CommandType = Data.CommandType.StoredProcedure 'Pass parameters required by the stored procedure cmd.Parameters.AddWithValue("@unitdd", DropDownList3.Text) cmd.Parameters.AddWithValue("@yeardd", DropDownList1.Text) cmd.Parameters.AddWithValue("@ignumdd", DropDownList2.Text) Dim errorcode As Integer = 0 Try conn.Open() cmd.ExecuteNonQuery() Catch ex As Exception errorcode = 1 Response.Write(ex) Finally conn.Close() End Try If errorcode = 0 Then 'Response.Redirect("IG_Maintain.aspx") End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End SubEnd Class
ASP code with update panelview plaincopy to clipboardprint?
No comments posted yet
Your Answer:
Login to answer
112
22
Other forums
simple php table loop
Hi all,
I've the following code
<?php // Create category options
Best way to cross matching large datasets
Hi,
Im running a script where am I cross matching about 200 000 data sets with each other. Ea
Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to
Executing an exe
Hi. I have some bizarre problem with exec (other any other method) to launch exe's. I am making a ga
Can't find a decent web analytics!!!
I've downloaded and installed Piwik. It's location detection based on IP addresses is fairly inaccur
Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate w
Is it possible to stop reservation creation in PM Order?
Hi All,
Is it possible to stop reservation creation in PM Order?
Thanks in adv
mysqli_fetch_assoc returns multiple arrays, how to return a single array
Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:
Code
Warehouse Management
Hi,
On our system, we have two storage locations ( A and B ) where A is the main factory
Post, not working, please help
The error is:
Method Not Allowed
The requested method POST is not allowed for the URL /student