473,756 Members | 7,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid with no data, not showing data

I have a DataGrid which displays data with the aid of a procedure.

I have tested the procedure inside the database and it is working
fine. The table inside the database has data that matches with the
parameter.
I have another procedure which adds another row to the table, which is
working fine inside the programming, and in the database.

However, I still cannot figure out what am I doing wrong with the
DataGrid configurations OR Database OR DataAdapter OR
SqlSelectComman d ... I really don't know yet and I have spent a lot of
time in this issue.
**On page Load a different page calls the method RefreshDataCrit eria,
which it supposes to refresh the data in the DataGrid***

I have other pages that do the same thing:
when the user clicks on a certain link, in the main page, the link
makes visible the control ( .ascx ) and then calls the function to
refresh the data of the DataGrid. The other pages are working fine,
except for this one.

I have tried with:
Private Sub Page_Load
(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles
MyBase.Load

If Not IsPostBack Then
RefreshDataCrit eria()
End If
End Sub

But nothing happens.
Below is additional information. Any help is extremely appreciated:
----------------------------------------------------------
Code inside the HTML part:

Code: ( html4strict )
<asp:datagrid id=dataGridCrit eria Width="466px" runat="server" Font-
Size="XX-Small" DataKeyField="C ourseCriteriaID "
DataMember="pro cWebSelectCours eCriteriaForSyl labus" DataSource="<%#
DtsCourseCriter ias31 %>" BorderColor="#3 366CC" BorderWidth="1p x"
BackColor="Whit e" CellPadding="4" BorderStyle="No ne"
AutoGenerateCol umns="False" PageSize="5" Font-Names="sans-serif"
AllowPaging="Tr ue" Height="120px">
<SelectedItemSt yle Font-Bold="True"
ForeColor="#CCF F99" BackColor="#009 999"></SelectedItemSty le>
<ItemStyle Font-Size="XX-Small" Font-Names="Arial"
Font-Bold="True" ForeColor="#003 399" BackColor="Whit e"></ItemStyle>
<HeaderStyle Font-Size="XX-Small" Font-Names="Arial"
Font-Bold="True" ForeColor="#CCC CFF" BackColor="#003 399"></
HeaderStyle>
<FooterStyle ForeColor="#003 399" BackColor="#99C CCC"></
FooterStyle>
<Columns>
<asp:BoundColum n DataField="Prof OrgCriteriaID"
HeaderText="Pro fOrgCriteriaID" ></asp:BoundColumn >
<asp:BoundColum n DataField="Prof OrgCriteriaCode "
HeaderText="Pro fOrgCriteriaCod e"></asp:BoundColumn >
<asp:BoundColum n DataField="Prof OrgCriteriaDesc r"
HeaderText="Pro fOrgCriteriaDes cr"></asp:BoundColumn >
<asp:BoundColum n DataField="Cour seCriteriaID"
HeaderText="Cou rseCriteriaID"> </asp:BoundColumn >
<asp:ButtonColu mn Text="Delete" CommandName="De lete">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:ButtonColum n>
</Columns>
<PagerStyle NextPageText="N ext Page"
PrevPageText="P revious Page" HorizontalAlign ="Center"
ForeColor="#003 399"
BackColor="#99C CCC"></PagerStyle>
</asp:datagrid>

-----------------------------------------------------------------------

Procedure:

Code: ( text )
CREATE PROCEDURE dbo.procWebSele ctCourseCriteri aForSyllabus

@CourseCode varchar(20)

AS

SELECT ProfOrgCriteria .ProfOrgCriteri aID,
ProfOrgCriteria .ProfOrgCriteri aCode,ProfOrgCr iteri
a.ProfOrgCriter iaDescr,CourseC riteria.CourseC riter iaID
FROM CourseCriteria INNER JOIN
ProfOrgCriteria ON
CourseCriteria. ProfOrgCriteria ID = ProfOrgCriteria .ProfOrgCriteri aID
WHERE (CourseCriteria .CourseCode = @CourseCode)
GO

---------------------------------------------------------

DataSet:
Code: ( html4strict )
<?xml version="1.0" standalone="yes "?>
<xs:schema id="dtsCourseCr iterias3" targetNamespace ="http://
www.tempuri.org/dtsCourseCriter ias3.xsd" xmlns:mstns="ht tp://
www.tempuri.org/dtsCourseCriter ias3.xsd" xmlns="http://www.tempuri.org/
dtsCourseCriter ias3.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified" >
<xs:element name="dtsCourse Criterias3" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="procWebSe lectCourseCrite riaForSyllabus" >
<xs:complexType >
<xs:sequence>
<xs:element name="ProfOrgCr iteriaID"
msdata:ReadOnly ="true" msdata:AutoIncr ement="true" type="xs:int" />
<xs:element name="ProfOrgCr iteriaCode" type="xs:string " /
>
<xs:element name="ProfOrgCr iteriaDescr"
type="xs:string " />
<xs:element name="CourseCri teriaID"
msdata:ReadOnly ="true" msdata:AutoIncr ement="true" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table">
<xs:complexType >
<xs:sequence>
<xs:element name="ProfOrgCr iteriaID"
msdata:ReadOnly ="true" msdata:AutoIncr ement="true" type="xs:int" />
<xs:element name="ProfOrgCr iteriaCode" type="xs:string " /
>
<xs:element name="ProfOrgCr iteriaDescr"
type="xs:string " />
<xs:element name="CourseCri teriaID"
msdata:ReadOnly ="true" msdata:AutoIncr ement="true" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="dtsCourse Criterias3Key1"
msdata:PrimaryK ey="true">
<xs:selector xpath=".//
mstns:procWebSe lectCourseCrite riaForSyllabus" />
<xs:field xpath="mstns:Pr ofOrgCriteriaID " />
<xs:field xpath="mstns:Co urseCriteriaID" />
</xs:unique>
<xs:unique name="Constrain t1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Table" />
<xs:field xpath="mstns:Pr ofOrgCriteriaID " />
<xs:field xpath="mstns:Co urseCriteriaID" />
</xs:unique>
</xs:element>
</xs:schema>
-----------------------------------------

VB.NET Code:
Code: ( text )
Public Class CourseCriteriaG rid
Inherits System.Web.UI.U serControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
InitializeCompo nent()
Dim configurationAp pSettings As
System.Configur ation.AppSettin gsReader = New
System.Configur ation.AppSettin gsReader
Me.SqlConnectio n1 = New System.Data.Sql Client.SqlConne ction
Me.sqlSelectCou rseCriteria = New
System.Data.Sql Client.SqlComma nd
Me.SqlCommandAd dCourseCriteria = New
System.Data.Sql Client.SqlComma nd
Me.DtsCourseCri terias31 = New
UniversalSyllab us.dtsCourseCri terias3
Me.SqlDataAdapt erCourseCriteri a = New
System.Data.Sql Client.SqlDataA dapter
Me.sqlCommandDe leteCourseCrite ria = New
System.Data.Sql Client.SqlComma nd
CType(Me.DtsCou rseCriterias31,
System.Componen tModel.ISupport Initialize).Beg inIni t()
'
'SqlConnection1
'
Me.SqlConnectio n1.ConnectionSt ring =
CType(configura tionAppSettings .GetValue("SqlC onnection1.Conn ectionString",
GetType(System. String)), String)
'
'sqlSelectCours eCriteria
'
Me.sqlSelectCou rseCriteria.Com mandText =
"[procWebSelectCo urseCriteriaFor Syllabus]"
Me.sqlSelectCou rseCriteria.Com mandType =
System.Data.Com mandType.Stored Procedure
Me.sqlSelectCou rseCriteria.Con nection = Me.SqlConnectio n1
Me.sqlSelectCou rseCriteria.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4,
System.Data.Par ameterDirection .ReturnValue, False, CType(0, Byte),
CType(0, Byte), "", System.Data.Dat aRowVersion.Cur rent, Nothing))
Me.sqlSelectCou rseCriteria.Par ameters.Add(New
System.Data.Sql Client.SqlParam eter("@CourseCo de",
System.Data.Sql DbType.VarChar, 20))
'
'SqlCommandAddC ourseCriteria
'
Me.SqlCommandAd dCourseCriteria .CommandText =
"[procWebInsertCo urseCriteria]"
Me.SqlCommandAd dCourseCriteria .CommandType =
System.Data.Com mandType.Stored Procedure
Me.SqlCommandAd dCourseCriteria .Connection = Me.SqlConnectio n1
Me.SqlCommandAd dCourseCriteria .Parameters.Add (New
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4,
System.Data.Par ameterDirection .ReturnValue, False, CType(0, Byte),
CType(0, Byte), "", System.Data.Dat aRowVersion.Cur rent, Nothing))
Me.SqlCommandAd dCourseCriteria .Parameters.Add (New
System.Data.Sql Client.SqlParam eter("@CourseCo de",
System.Data.Sql DbType.VarChar, 20))
Me.SqlCommandAd dCourseCriteria .Parameters.Add (New
System.Data.Sql Client.SqlParam eter("@ProfOrgC riteriaID",
System.Data.Sql DbType.Int, 4))
'
'DtsCourseCrite rias31
'
Me.DtsCourseCri terias31.DataSe tName = "dtsCourseCrite rias3"
Me.DtsCourseCri terias31.Enforc eConstraints = False
Me.DtsCourseCri terias31.Locale = New
System.Globaliz ation.CultureIn fo("en-US")
'
'SqlDataAdapter CourseCriteria
'
Me.SqlDataAdapt erCourseCriteri a.SelectCommand =
Me.sqlSelectCou rseCriteria
'
'sqlCommandDele teCourseCriteri a
'
Me.sqlCommandDe leteCourseCrite ria.CommandText =
"[procWebDeleteCo urseCriteria]"
Me.sqlCommandDe leteCourseCrite ria.CommandType =
System.Data.Com mandType.Stored Procedure
Me.sqlCommandDe leteCourseCrite ria.Connection =
Me.SqlConnectio n1
Me.sqlCommandDe leteCourseCrite ria.Parameters. Add(N ew
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4,
System.Data.Par ameterDirection .ReturnValue, False, CType(0, Byte),
CType(0, Byte), "", System.Data.Dat aRowVersion.Cur rent, Nothing))
Me.sqlCommandDe leteCourseCrite ria.Parameters. Add(N ew
System.Data.Sql Client.SqlParam eter("@CourseCr iteriaID",
System.Data.Sql DbType.Int, 4))
CType(Me.DtsCou rseCriterias31,
System.Componen tModel.ISupport Initialize).End Init( )

End Sub

Protected WithEvents SqlConnection1 As
System.Data.Sql Client.SqlConne ction
' Protected WithEvents DtsCourseCriter ias1 As
UniversalSyllab us.dtsCourseCri terias3
Protected WithEvents sqlSelectCourse Criteria As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlCommandAddCo urseCriteria As
System.Data.Sql Client.SqlComma nd
Protected WithEvents DtsCourseCriter ias31 As
UniversalSyllab us.dtsCourseCri terias3
Protected WithEvents SqlDataAdapterC ourseCriteria As
System.Data.Sql Client.SqlDataA dapter
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents dataGridCriteri a As
System.Web.UI.W ebControls.Data Grid
Protected WithEvents buttonAddCriter ia As
System.Web.UI.W ebControls.Butt on
Protected WithEvents sqlCommandDelet eCourseCriteria As
System.Data.Sql Client.SqlComma nd

'NOTE: The following placeholder declaration is required by the
Web Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

End Sub

------------------------------
'NEXT IS THE METHOD THAT SUPPOSES TO BIND DATA TO THE DATAGRID
------------------------------

Public Sub RefreshDataCrit eria()

Me.sqlSelectCou rseCriteria.Par ameters("@Cours eCode").Value =
Session("Course Code")
Me.SqlDataAdapt erCourseCriteri a.Fill(Me.DtsCo urseCriterias31 )
Me.dataGridCrit eria.DataBind()

End Sub

---------------------------------
---------------------------------

Public Event addCriteria()
Private Sub buttonAddCriter ia_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles buttonAddCriter ia.Click
RaiseEvent addCriteria()

End Sub

Private Sub dataGridCriteri a_ItemDataBound (ByVal sender As
System.Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs)
'Enable javascript to alert about the delete
If e.Item.ItemType <ListItemType.H eader And _
e.Item.ItemType <ListItemType.F ooter And e.Item.ItemType <>
ListItemType.Pa ger Then
Dim deleteButton2 As LinkButton =
e.Item.Cells(2) .Controls(0)
deleteButton2.A ttributes("oncl ick") = "javascript:ret urn "
& _
"confirm('A re you sure you want to delete Course Criteria:
" & _
DataBinder.Eval (e.Item.DataIte m, "CriteriaDescri ption") &
" ?')"
End If

End Sub
Private Sub dataGridCriteri a_PageIndexChan ged(ByVal source As
System.Object, ByVal e As
System.Web.UI.W ebControls.Data GridPageChanged Event Args)
Me.dataGridCrit eria.CurrentPag eIndex = e.NewPageIndex
RefreshDataCrit eria()
End Sub
Private Sub dataGridCriteri a_ItemCommand(B yVal source As
System.Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs )
Select Case (CType(e.Comman dSource, LinkButton)).Co mmandName
Case "Delete"

Me.sqlCommandDe leteCourseCrite ria.Parameters( "@CourseCriteri aID").Value
= Me.dataGridCrit eria.DataKeys(e .Item.ItemIndex )
Me.SqlConnectio n1.Open()
Me.sqlCommandDe leteCourseCrite ria.ExecuteNonQ uery( )
Me.SqlConnectio n1.Close()

Me.dataGridCrit eria.EditItemIn dex = -1

If Me.dataGridCrit eria.CurrentPag eIndex >= 1 And
Me.dataGridCrit eria.Items.Coun t = 1 Then
Me.dataGridCrit eria.CurrentPag eIndex =
Me.dataGridCrit eria.CurrentPag eIndex - 1

End If

RefreshDataCrit eria()
End Select
End Sub
End Class

-------------------------------------

Thank you!,
NMM

May 20 '07 #1
0 1771

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

Similar topics

0
1104
by: irene | last post by:
Hi,I am trying to update a datagrid of a web page but I am having the problems. I am using the sqldataadapter and dataset to bind it to a datagrid. The web page shows a list of people(the datagrid data) on a certain class and the director will need to approve them. I have a bit datatype field called "approved" on the database and the checkbox on the webpage showing the field "approved" value. The director will check the checkbox to approve...
2
4333
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know how to use this code? please help! http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
2
2260
by: enak | last post by:
I can not get my datagrid to page. I have a datagrid that I can sort 2 of the columns. This works great. I added paging and when I display the dg it shows 5 pages. (I am showing page numbers at the bottom of the dg.) When I click on the pages nothing happens until I get to the last page. Then and only then is the last page displayed. If I go back through the pages the second to last page displayes the first page again.
2
2339
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last, Fax, Phone, Category). Put an Edit column at the end... Now what?! If you go into Edit mode -- you can only edit 5 cells -- not all the rest of the Record's fields...not enough!
6
1453
by: Dee | last post by:
Hi The paging numbers of my DataGrid dont actually page. What can be the cause? Everyting else seems to work. Thanks Dee
5
2791
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
4
3113
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll horizontally to view these coloumn names. So I want to group them into categories which will fit into a page. A user clicks a category and the category should
2
6593
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.