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 Like 22 Dislike
Previous forums Next forums
Other forums

Unifying logins of two different scripts
I have two different game scripts which I want to embed on my own site. The problem is I don't want

Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:

Add trigger to UpdatePanel programmatically
Hi,I'm working on a website which uses AJAX and Masterpages. What I have is an AJAX UpdatePanel whi

Generating unique numbers using php
Hi,
I need help in generating unique number using php.I tired using rand() in php.But, by using r

How to get the previous months last date....
Here's my wittle problem. I suck at working with dates.

So today is 10/20/2009, i need to fig

Problem writing URL into database
How would I write this into the database?

<?php echo "http://".$_SERVER['SER

cPanel API
Hi Guys,

Need a little guidance. I'm trying to get my script to communicate with cPanel (or W

Creating a unique 'control panel' for each user
Hi there,

I'm thinking of designing a site that will allow users to sign up and have their ow

Output Buffering question
Hi all,

I've been trying to wrap my head around output buffering. So far I've found tons of

Quick Question about echo value
Hey guys, I'm trying to get something to show differently in one of my scripts. I'm trying to make

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash