473,416 Members | 1,726 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,416 software developers and data experts.

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
SqlSelectCommand ... 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 RefreshDataCriteria,
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.EventArgs) Handles
MyBase.Load

If Not IsPostBack Then
RefreshDataCriteria()
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=dataGridCriteria Width="466px" runat="server" Font-
Size="XX-Small" DataKeyField="CourseCriteriaID"
DataMember="procWebSelectCourseCriteriaForSyllabus " DataSource="<%#
DtsCourseCriterias31 %>" BorderColor="#3366CC" BorderWidth="1px"
BackColor="White" CellPadding="4" BorderStyle="None"
AutoGenerateColumns="False" PageSize="5" Font-Names="sans-serif"
AllowPaging="True" Height="120px">
<SelectedItemStyle Font-Bold="True"
ForeColor="#CCFF99" BackColor="#009999"></SelectedItemStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Arial"
Font-Bold="True" ForeColor="#003399" BackColor="White"></ItemStyle>
<HeaderStyle Font-Size="XX-Small" Font-Names="Arial"
Font-Bold="True" ForeColor="#CCCCFF" BackColor="#003399"></
HeaderStyle>
<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></
FooterStyle>
<Columns>
<asp:BoundColumn DataField="ProfOrgCriteriaID"
HeaderText="ProfOrgCriteriaID"></asp:BoundColumn>
<asp:BoundColumn DataField="ProfOrgCriteriaCode"
HeaderText="ProfOrgCriteriaCode"></asp:BoundColumn>
<asp:BoundColumn DataField="ProfOrgCriteriaDescr"
HeaderText="ProfOrgCriteriaDescr"></asp:BoundColumn>
<asp:BoundColumn DataField="CourseCriteriaID"
HeaderText="CourseCriteriaID"></asp:BoundColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:ButtonColumn>
</Columns>
<PagerStyle NextPageText="Next Page"
PrevPageText="Previous Page" HorizontalAlign="Center"
ForeColor="#003399"
BackColor="#99CCCC"></PagerStyle>
</asp:datagrid>

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

Procedure:

Code: ( text )
CREATE PROCEDURE dbo.procWebSelectCourseCriteriaForSyllabus

@CourseCode varchar(20)

AS

SELECT ProfOrgCriteria.ProfOrgCriteriaID,
ProfOrgCriteria.ProfOrgCriteriaCode,ProfOrgCriteri
a.ProfOrgCriteriaDescr,CourseCriteria.CourseCriter iaID
FROM CourseCriteria INNER JOIN
ProfOrgCriteria ON
CourseCriteria.ProfOrgCriteriaID = ProfOrgCriteria.ProfOrgCriteriaID
WHERE (CourseCriteria.CourseCode = @CourseCode)
GO

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

DataSet:
Code: ( html4strict )
<?xml version="1.0" standalone="yes"?>
<xs:schema id="dtsCourseCriterias3" targetNamespace="http://
www.tempuri.org/dtsCourseCriterias3.xsd" xmlns:mstns="http://
www.tempuri.org/dtsCourseCriterias3.xsd" xmlns="http://www.tempuri.org/
dtsCourseCriterias3.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="dtsCourseCriterias3" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="procWebSelectCourseCriteriaForSyllabus">
<xs:complexType>
<xs:sequence>
<xs:element name="ProfOrgCriteriaID"
msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="ProfOrgCriteriaCode" type="xs:string" /
>
<xs:element name="ProfOrgCriteriaDescr"
type="xs:string" />
<xs:element name="CourseCriteriaID"
msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="ProfOrgCriteriaID"
msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="ProfOrgCriteriaCode" type="xs:string" /
>
<xs:element name="ProfOrgCriteriaDescr"
type="xs:string" />
<xs:element name="CourseCriteriaID"
msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="dtsCourseCriterias3Key1"
msdata:PrimaryKey="true">
<xs:selector xpath=".//
mstns:procWebSelectCourseCriteriaForSyllabus" />
<xs:field xpath="mstns:ProfOrgCriteriaID" />
<xs:field xpath="mstns:CourseCriteriaID" />
</xs:unique>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Table" />
<xs:field xpath="mstns:ProfOrgCriteriaID" />
<xs:field xpath="mstns:CourseCriteriaID" />
</xs:unique>
</xs:element>
</xs:schema>
-----------------------------------------

VB.NET Code:
Code: ( text )
Public Class CourseCriteriaGrid
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
Dim configurationAppSettings As
System.Configuration.AppSettingsReader = New
System.Configuration.AppSettingsReader
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.sqlSelectCourseCriteria = New
System.Data.SqlClient.SqlCommand
Me.SqlCommandAddCourseCriteria = New
System.Data.SqlClient.SqlCommand
Me.DtsCourseCriterias31 = New
UniversalSyllabus.dtsCourseCriterias3
Me.SqlDataAdapterCourseCriteria = New
System.Data.SqlClient.SqlDataAdapter
Me.sqlCommandDeleteCourseCriteria = New
System.Data.SqlClient.SqlCommand
CType(Me.DtsCourseCriterias31,
System.ComponentModel.ISupportInitialize).BeginIni t()
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString =
CType(configurationAppSettings.GetValue("SqlConnec tion1.ConnectionString",
GetType(System.String)), String)
'
'sqlSelectCourseCriteria
'
Me.sqlSelectCourseCriteria.CommandText =
"[procWebSelectCourseCriteriaForSyllabus]"
Me.sqlSelectCourseCriteria.CommandType =
System.Data.CommandType.StoredProcedure
Me.sqlSelectCourseCriteria.Connection = Me.SqlConnection1
Me.sqlSelectCourseCriteria.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte),
CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.sqlSelectCourseCriteria.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CourseCode",
System.Data.SqlDbType.VarChar, 20))
'
'SqlCommandAddCourseCriteria
'
Me.SqlCommandAddCourseCriteria.CommandText =
"[procWebInsertCourseCriteria]"
Me.SqlCommandAddCourseCriteria.CommandType =
System.Data.CommandType.StoredProcedure
Me.SqlCommandAddCourseCriteria.Connection = Me.SqlConnection1
Me.SqlCommandAddCourseCriteria.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte),
CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlCommandAddCourseCriteria.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CourseCode",
System.Data.SqlDbType.VarChar, 20))
Me.SqlCommandAddCourseCriteria.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@ProfOrgCriter iaID",
System.Data.SqlDbType.Int, 4))
'
'DtsCourseCriterias31
'
Me.DtsCourseCriterias31.DataSetName = "dtsCourseCriterias3"
Me.DtsCourseCriterias31.EnforceConstraints = False
Me.DtsCourseCriterias31.Locale = New
System.Globalization.CultureInfo("en-US")
'
'SqlDataAdapterCourseCriteria
'
Me.SqlDataAdapterCourseCriteria.SelectCommand =
Me.sqlSelectCourseCriteria
'
'sqlCommandDeleteCourseCriteria
'
Me.sqlCommandDeleteCourseCriteria.CommandText =
"[procWebDeleteCourseCriteria]"
Me.sqlCommandDeleteCourseCriteria.CommandType =
System.Data.CommandType.StoredProcedure
Me.sqlCommandDeleteCourseCriteria.Connection =
Me.SqlConnection1
Me.sqlCommandDeleteCourseCriteria.Parameters.Add(N ew
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte),
CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.sqlCommandDeleteCourseCriteria.Parameters.Add(N ew
System.Data.SqlClient.SqlParameter("@CourseCriteri aID",
System.Data.SqlDbType.Int, 4))
CType(Me.DtsCourseCriterias31,
System.ComponentModel.ISupportInitialize).EndInit( )

End Sub

Protected WithEvents SqlConnection1 As
System.Data.SqlClient.SqlConnection
' Protected WithEvents DtsCourseCriterias1 As
UniversalSyllabus.dtsCourseCriterias3
Protected WithEvents sqlSelectCourseCriteria As
System.Data.SqlClient.SqlCommand
Protected WithEvents SqlCommandAddCourseCriteria As
System.Data.SqlClient.SqlCommand
Protected WithEvents DtsCourseCriterias31 As
UniversalSyllabus.dtsCourseCriterias3
Protected WithEvents SqlDataAdapterCourseCriteria As
System.Data.SqlClient.SqlDataAdapter
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents dataGridCriteria As
System.Web.UI.WebControls.DataGrid
Protected WithEvents buttonAddCriteria As
System.Web.UI.WebControls.Button
Protected WithEvents sqlCommandDeleteCourseCriteria As
System.Data.SqlClient.SqlCommand

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

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

#End Region

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

End Sub

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

Public Sub RefreshDataCriteria()

Me.sqlSelectCourseCriteria.Parameters("@CourseCode ").Value =
Session("CourseCode")
Me.SqlDataAdapterCourseCriteria.Fill(Me.DtsCourseC riterias31)
Me.dataGridCriteria.DataBind()

End Sub

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

Public Event addCriteria()
Private Sub buttonAddCriteria_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles buttonAddCriteria.Click
RaiseEvent addCriteria()

End Sub

Private Sub dataGridCriteria_ItemDataBound(ByVal sender As
System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
'Enable javascript to alert about the delete
If e.Item.ItemType <ListItemType.Header And _
e.Item.ItemType <ListItemType.Footer And e.Item.ItemType <>
ListItemType.Pager Then
Dim deleteButton2 As LinkButton =
e.Item.Cells(2).Controls(0)
deleteButton2.Attributes("onclick") = "javascript:return "
& _
"confirm('Are you sure you want to delete Course Criteria:
" & _
DataBinder.Eval(e.Item.DataItem, "CriteriaDescription") &
" ?')"
End If

End Sub
Private Sub dataGridCriteria_PageIndexChanged(ByVal source As
System.Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEvent Args)
Me.dataGridCriteria.CurrentPageIndex = e.NewPageIndex
RefreshDataCriteria()
End Sub
Private Sub dataGridCriteria_ItemCommand(ByVal source As
System.Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Select Case (CType(e.CommandSource, LinkButton)).CommandName
Case "Delete"

Me.sqlCommandDeleteCourseCriteria.Parameters("@Cou rseCriteriaID").Value
= Me.dataGridCriteria.DataKeys(e.Item.ItemIndex)
Me.SqlConnection1.Open()
Me.sqlCommandDeleteCourseCriteria.ExecuteNonQuery( )
Me.SqlConnection1.Close()

Me.dataGridCriteria.EditItemIndex = -1

If Me.dataGridCriteria.CurrentPageIndex >= 1 And
Me.dataGridCriteria.Items.Count = 1 Then
Me.dataGridCriteria.CurrentPageIndex =
Me.dataGridCriteria.CurrentPageIndex - 1

End If

RefreshDataCriteria()
End Select
End Sub
End Class

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

Thank you!,
NMM

May 20 '07 #1
0 1756

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

Similar topics

0
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...
2
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...
1
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...
2
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...
2
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,...
6
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
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...
4
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...
2
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.