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
Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.
Run function every 5 mins ??
I have a function PostMessage()
How can I run it every 5 mins ??
Hom to make one url to open together with another url
I have a chat, which i want to be opened, as soon as the users login to the site. As it is now, when
PHP onsubmit in the form not going to the fuction.
I have a form through ‘onsubmit’ calling a function validation(). But not going to the
ASP.NET Validation Event Cycle
Hi,
I have asp button as follow:problem with GROUP BY and ORDER BY
i usually use this query to display the last 10 entries from a sql table:
Code: $query = &quo
How to make a input/output field with multiple lines
Hello.
I put a input/output field on the screen but I could not change height of it. I need to
Passing PHP variables from one page to another
Hello-
I'm having trouble figuring out how to transport a variable from one php file to anoth
first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see
Shuffle between users ??
I have multiple $users in table. I need to send them $message.
I need to send the next messag