473,399 Members | 3,888 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,399 software developers and data experts.

My datagrid does not show the query from dataset

Hi,

I am new in ASP.Net. I used 2 ways of coding to get the same result. The
first one is by typing all the codes directly to the asp.net page and it
works. The code looks like this:

<%@ import namespace = "System.Data" %>
<%@ import namespace = "System.Data.SQLClient" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="vb" runat="server">
Sub Page_Load()
Dim strConnection As String
Dim strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As SQLConnection
Dim objAdapter As SQLDataAdapter
'Dim dgCustomer as New DataGrid()
strConnection = "server=kresnadi-fonny;database=AGInventory;" & _
"uid=sa;password=kresnadi"

strSQL = "Select * from tblCustomer;"

objConnection = new SQLConnection(strConnection)
objAdapter = New SQLDataAdapter(strSQL, objConnection)

objAdapter.Fill(objDataSet, "tblCustomer")

dgCustomer.DataSource = objDataSet.Tables("tblCustomer").DefaultView
dgCustomer.DataBind()

End Sub
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="Label1" runat="server" Font-Bold="True"
Font-Size="X-Large" Font-Names="P22 Tai Chi" Height="81px" Width="366px">Asia
Gallery</asp:label><br>
<br>
<br>
<table>
<tr>
<td><asp:datagrid id="dgCustomer" runat="server"></asp:datagrid></td>
</tr>
</table>
</form>
</body>
</HTML>

The problem arises when I use asp.net built in component, such as
SQLDataAdapter, SQLConnection, DataSet, and DataGrid. I drag the table name
from Server Explorer and it generates SQLDataAdapter and SQLConnection
automatically. Then, I add DataSet and DataGrid. The Datasource of datagrid,
I points to the dataset. I also assigns the datamember.
Then, when on page load, I type this function:

DataSet21.Clear()
SqlDataAdapter1.Fill(DataSet21)

When I run the code, it displays blank page. It does not even generate error
message.

Please help. Thanks.
Feb 13 '06 #1
0 776

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
2
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction...
1
by: jm | last post by:
I manually put a datagrid in on a form. I then added this code to an event to populate it: OdbcConnection conn = new OdbcConnection("DSN=CardBase"); sqlCardHolders = "SELECT * FROM...
5
by: Sanddevil | last post by:
Hi there - I hope someone out there can help me! I'm using a .Net DataGrid Class to show the results of a SQL query in a spreadsheet type control. The code, which works fine is: iRowCount =...
6
by: Jim | last post by:
Can someone, please, show me how to display the results of a stored procedure in a VB.NET datagrid on a winform? I'm a newbie. Here's my SQL 2000 stored precedure that returns the status of...
9
by: mfahnestock | last post by:
Hi all! Aspiring VB programmer losing hair <And Sleep> over this problem. I have spent several days researching through the various usenets and resources to no avail, and so now I am taking the...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.