473,765 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid problem not displaying anything on the screen!!

Hello guys i made a Datagrid with Editing,Update and Cancel using VS.NET. to
my surprise nothing is on the screen after compilation ..

By code below:-
Imports System.Data
Imports System.Data.Sql Client
Imports System.Web.UI.W ebControls
Imports System.Web.UI.H tmlControls
Public Class datagrid_edit
Inherits System.Web.UI.P age

Protected WithEvents MenuGrid As System.Web.UI.W ebControls.Data Grid

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

'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
'Put user code to initialize the page here
End Sub
Sub BindDataGrid()

Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String

DBConnection = New
SqlConnection(" server=(local); database=Northw ind;integrated security=true;" )
DBConnection.Op en()
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection)
DBReader = DBCommand.Execu teReader()
MenuGrid.DataSo urce = DBReader
MenuGrid.DataBi nd()
DBReader.Close( )
DBConnection.Cl ose()

End Sub

Sub EditRecord(ByVa l Src As Object, ByVal Args As
DataGridCommand EventArgs)
MenuGrid.EditIt emIndex = Args.Item.ItemI ndex
BindDataGrid()
End Sub

Sub UpdateRecord(By Val Src As Object, ByVal Args As
DataGridCommand EventArgs)
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String

Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0),
TextBox).Text
Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text
Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text
Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text
Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text

'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0),
TextBox).Text

SQLString = "UPDATE treetable SET " & _
"ParentID = '" & ParentID & "', " & _
"FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _
"NacigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _
"Target = " & Target & ", " & _
"WHERE FileCategoryID ='" & FileCategoryID & "'"
'"ItemQuanti ty = " & ItemQuantity & " " & _
'"WHERE ItemNumber = '" & ItemNumber & "'"

DBConnection = New
SqlConnection(" server=(local); database=Northw ind;integrated security=true;" )
DBConnection.Op en()
DBCommand = New SqlCommand(SQLS tring, DBConnection)
DBCommand.Execu teNonQuery()
DBConnection.Cl ose()

MenuGrid.EditIt emIndex = -1
BindDataGrid()

End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As
DataGridCommand EventArgs)
MenuGrid.EditIt emIndex = -1
BindDataGrid()
End Sub

End Class

Html Code Below:-
-------------------

<asp:DataGrid id="MenuGrid" runat="server"
OnEditCommand=" EditRecord"
OnUpdateCommand ="UpdateReco rd"
OnCancelCommand ="CancelReco rd"
AutoGenerateCol umns="False">

<Columns>

<asp:BoundColum n
HeaderText="Par entID"
DataField="Pare ntID"/>
<asp:BoundColum n
HeaderText="Fil eCategory"
DataField="File Category"/>
<asp:BoundColum n
HeaderText="Nav igateUrl"
DataField="Navi gateUrl"/>
<asp:BoundColum n
HeaderText="tar get"
DataField="targ et"/>

<asp:EditComman dColumn
HeaderText="Edi ting"
EditText="Edit"
UpdateText="Upd ate"
CancelText="Can cel"/>

</Columns>

</asp:DataGrid>

Nov 18 '05 #1
1 1617
Well i now know what i was doing wrong!
I wasn't binding it in Page_Load.!!

"Patrick.O. Ige" wrote:
Hello guys i made a Datagrid with Editing,Update and Cancel using VS.NET. to
my surprise nothing is on the screen after compilation ..

By code below:-
Imports System.Data
Imports System.Data.Sql Client
Imports System.Web.UI.W ebControls
Imports System.Web.UI.H tmlControls
Public Class datagrid_edit
Inherits System.Web.UI.P age

Protected WithEvents MenuGrid As System.Web.UI.W ebControls.Data Grid

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

'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
'Put user code to initialize the page here
End Sub
Sub BindDataGrid()

Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String

DBConnection = New
SqlConnection(" server=(local); database=Northw ind;integrated security=true;" )
DBConnection.Op en()
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection)
DBReader = DBCommand.Execu teReader()
MenuGrid.DataSo urce = DBReader
MenuGrid.DataBi nd()
DBReader.Close( )
DBConnection.Cl ose()

End Sub

Sub EditRecord(ByVa l Src As Object, ByVal Args As
DataGridCommand EventArgs)
MenuGrid.EditIt emIndex = Args.Item.ItemI ndex
BindDataGrid()
End Sub

Sub UpdateRecord(By Val Src As Object, ByVal Args As
DataGridCommand EventArgs)
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String

Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0),
TextBox).Text
Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text
Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text
Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text
Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text

'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0),
TextBox).Text

SQLString = "UPDATE treetable SET " & _
"ParentID = '" & ParentID & "', " & _
"FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _
"NacigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _
"Target = " & Target & ", " & _
"WHERE FileCategoryID ='" & FileCategoryID & "'"
'"ItemQuanti ty = " & ItemQuantity & " " & _
'"WHERE ItemNumber = '" & ItemNumber & "'"

DBConnection = New
SqlConnection(" server=(local); database=Northw ind;integrated security=true;" )
DBConnection.Op en()
DBCommand = New SqlCommand(SQLS tring, DBConnection)
DBCommand.Execu teNonQuery()
DBConnection.Cl ose()

MenuGrid.EditIt emIndex = -1
BindDataGrid()

End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As
DataGridCommand EventArgs)
MenuGrid.EditIt emIndex = -1
BindDataGrid()
End Sub

End Class

Html Code Below:-
-------------------

<asp:DataGrid id="MenuGrid" runat="server"
OnEditCommand=" EditRecord"
OnUpdateCommand ="UpdateReco rd"
OnCancelCommand ="CancelReco rd"
AutoGenerateCol umns="False">

<Columns>

<asp:BoundColum n
HeaderText="Par entID"
DataField="Pare ntID"/>
<asp:BoundColum n
HeaderText="Fil eCategory"
DataField="File Category"/>
<asp:BoundColum n
HeaderText="Nav igateUrl"
DataField="Navi gateUrl"/>
<asp:BoundColum n
HeaderText="tar get"
DataField="targ et"/>

<asp:EditComman dColumn
HeaderText="Edi ting"
EditText="Edit"
UpdateText="Upd ate"
CancelText="Can cel"/>

</Columns>

</asp:DataGrid>

Nov 18 '05 #2

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

Similar topics

4
1621
by: Christiaan | last post by:
Hi, I have two classes, Department and Employer, the Department contains an ArrayList (employers) filled with Employer objects. I want to display an ArrayList filled with Department objects using a Datagrid. Therefor, I do a setDatabinding with the Deparments ArrayList and I create two DatagridTableStyle objects, both with mappingname "ArrayList", and add them to the Datagrid. However, if I want to add the second DatagridTableStyle, I get...
1
1315
by: holy | last post by:
Hi If the DataSource is empty, I just want to avoid showing the Empty DataGrid with Column headers. How can I do this TIA Holysmoke
3
996
by: Sandy | last post by:
Hello - I didn't exactly know what to put in the Subject line, but here's my problem. I have the following in my html. I would like to put a comma in after the city. I tried just putting it in between the %> and </td>, but the comma displays with an extra space before it., e.g. "someCity ," I want "someCity,"
3
2140
by: Gerhard | last post by:
I would like a DataGrid I am using to show a default number of rows (10) with the heading, even if the dataset it is bound to returns less than that number of rows (0-9). It is a databound grid that sometime returns less than 10 rows (paging is enabled with a row count of 10). I would like the grid to always show 10 rows (blank rows if no data bound to them). Is there a way to do this?
4
1907
by: Rosko | last post by:
Hello - I'm displaying a SQL Server text field in a bound column. The text field has line breaks (CrLf - 0D0A) but the text displays in a long string in the DataGrid. Anybody know how to display them? -- Rosko
4
1765
by: Brad | last post by:
I have a file that downloaded a CSV file for the user based upon some information gathered from the Database. My file was working fine until recently (I believe that my hosting company did something when they upgraded to PHP5). Everytime a user tries to download the file, it displays the contents on the screen. Here is what I have for my file handling. Am I missing anything obvious? when called, $filecontent is displayed to the...
38
5078
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
0
9568
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
10156
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
10007
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...
1
9951
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
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...
1
7375
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
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();...
1
3924
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
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.