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

imap: how to save a copy of sent emails to sent elements
Hello my friends,

I am writing an online emailing application with inbox outbox/sent elements

Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s

Display search result
Hi!

I have a SQL database with information about albums and track (music).

This is wh

email CODING Problem
Email coding problem.

I need to send a section of the info to $tf and the same as a Cc to $em

Update Myspace status with CURL
Logging in:

Code: <?php

class Myspace
{
function login($username, $pa

Get last modified date of web page
Hai All,

In php how can i get last modified date of a give web page . I have tried to g

php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from th

Apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

Question handling xml data
Hello,

I have sucessfull followed this tutorial
http://www.phpfreaks.com/tutorial/handlin

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

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