473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

GridView Problem

44
Hi Friends

I have designed a form with 2 label boxes, 2 text boxes & 1 command button. If I click the command button then, the value entered in the text boxes should be inserted in the db & at the same time it should display in the grid view. The platform is ASP.NET with SQL SERVER 2000.

The coding I have given is
Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data
  3. Imports System.Data.SqlClient
  4. '------------------------------------------------------------------------------------
  5. Dim con As SqlConnection
  6.     Dim cmd As SqlCommand
  7.     Dim dgcmd As SqlCommand
  8.     Dim str, str1 As String
  9.     Dim dgstr As String
  10.     Dim da As SqlDataAdapter
  11.     Dim ds As DataSet
  12. '------------------------------------------------------------------------------------
  13. Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
  14.         str = "user id=sa;password=;data source=AURO-RA4;initial catalog=suganya;server=AURO-RA4"
  15.         con = New SqlConnection(str)
  16.         Try
  17.             con.Open()
  18.         Catch
  19.         End Try
  20.         str1 = "Insert into theater values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
  21.         cmd = New SqlCommand(str1, con)
  22.         cmd.ExecuteNonQuery()
  23.         con.Close()
  24.         Response.Write("Inserted")
  25.         dgstr = "select * from theater"
  26.         dgcmd = New SqlCommand(dgstr, con)
  27.         da = New SqlDataAdapter(dgstr, con)
  28.         ds = New DataSet()
  29.         da.Fill(ds)
  30.         GridView1.DataSource = ds
  31.         GridView1.DataBind()
  32.     End Sub
  33.  
Here the records are getting inserted but the GridView1 is not getting visible while running. There is also no error
Mar 22 '08 #1
3 963
Fuhrer
30
Hi Friends

I have designed a form with 2 label boxes, 2 text boxes & 1 command button. If I click the command button then, the value entered in the text boxes should be inserted in the db & at the same time it should display in the grid view. The platform is ASP.NET with SQL SERVER 2000.
...

Here the records are getting inserted but the GridView1 is not getting visible while running. There is also no error

Hi there,
i THINK u should put this piece of your code before Response.Write("Inserted"):
Expand|Select|Wrap|Line Numbers
  1. (
  2.         dgstr = "select * from theater"
  3.         dgcmd = New SqlCommand(dgstr, con)
  4.         da = New SqlDataAdapter(dgstr, con)
  5.         ds = New DataSet()
  6.         da.Fill(ds)
  7.         GridView1.DataSource = ds
  8.         GridView1.DataBind()
  9.  
  10.         Response.Write("Inserted")
  11. )
Mar 22 '08 #2
Frinavale
9,735 Expert Mod 8TB
Hi Friends

I have designed a form with 2 label boxes, 2 text boxes & 1 command button. If I click the command button then, the value entered in the text boxes should be inserted in the db & at the same time it should display in the grid view. The platform is ASP.NET with SQL SERVER 2000.

The coding I have given is
Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data
  3. Imports System.Data.SqlClient
  4. '------------------------------------------------------------------------------------
  5. Dim con As SqlConnection
  6.     Dim cmd As SqlCommand
  7.     Dim dgcmd As SqlCommand
  8.     Dim str, str1 As String
  9.     Dim dgstr As String
  10.     Dim da As SqlDataAdapter
  11.     Dim ds As DataSet
  12. '------------------------------------------------------------------------------------
  13. Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
  14.         str = "user id=sa;password=;data source=AURO-RA4;initial catalog=suganya;server=AURO-RA4"
  15.         con = New SqlConnection(str)
  16.         Try
  17.             con.Open()
  18.         Catch
  19.         End Try
  20.         str1 = "Insert into theater values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
  21.         cmd = New SqlCommand(str1, con)
  22.         cmd.ExecuteNonQuery()
  23.         con.Close()
  24.         Response.Write("Inserted")
  25.         dgstr = "select * from theater"
  26.         dgcmd = New SqlCommand(dgstr, con)
  27.         da = New SqlDataAdapter(dgstr, con)
  28.         ds = New DataSet()
  29.         da.Fill(ds)
  30.         GridView1.DataSource = ds
  31.         GridView1.DataBind()
  32.     End Sub
  33.  
Here the records are getting inserted but the GridView1 is not getting visible while running. There is also no error
Are you sure that "select * from theater" returns anything?
This type of thing typically happens when there is nothing for the GridView to display...by this I mean that the GridView's data source has nothing in it.

-Frinny
Mar 22 '08 #3
malav123
217 100+
You can check the code by Putting break points Otherwise in .aspx page use the property "EmptyDataText" in gridview tag to check whether the data comes in data table or not....
Mar 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
2
by: Loading name... | last post by:
Hey asp.net 2.0 I have a GridView on my webpage. This GridView's datasource is a SqlDataSource. The SqlDataSource returns 3 columns. Here is my problem: My GridView consist of 3 columns...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
8
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I am trying to get a list of files from a specified directory using the System.IO namespace classes, and then use that list as the datasource for a GridView. I have been able to do this...
1
by: Jeff | last post by:
ASP.NET 2.0 I've got problems with the right column in my GridView. The GridView consist of 2 columns, the problem column is the column on the right side. The problem is that it looks like...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.