473,595 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid based on arraylist not editable

I have a webform with a two-column datagrid based on an Arraylist. The
Arraylist draws the data for the two columns from two different tables
in an SQL database. The data is displayed in datagrid as expected but
when user clicks the Edit link, the cells do NOT turn into editable
text boxes. I actually need only the first column to be editable but
any ideas on getting the whole row editable would help at first.
Apologies for the amount of code that follows:
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 55px;
POSITION: absolute; TOP: 59px" runat="server" Font-Size="Smaller"
Font-Names="Arial" Height="120px" Width="400px" ShowHeader="Tru e">
<Columns>
<asp:EditComman dColumn ButtonType="Lin kButton"
UpdateText="Upd ate" CancelText="Can cel"
EditText="Edit" ></asp:EditCommand Column>
</Columns>
</asp:datagrid>

CODE BEHIND:

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

Me.SqlConnectio n1.ConnectionSt ring = Global.Connecti onString
Me.SqlConnectio n2.ConnectionSt ring = Global.Connecti onString

If Me.IsPostBack = False Then
Call FillDatagrid()
End If

End Sub

Function FillDatagrid()
Dim arrReportHeadin g As New ArrayList()
Dim strSQl As String
Dim strSQl2 As String
Dim cmdSubjectList As SqlClient.SqlCo mmand
Dim cmdTblNameList As SqlClient.SqlCo mmand

Dim dr As SqlClient.SqlDa taReader
Dim dr2 As SqlClient.SqlDa taReader

strSQl = "SELECT ReportDesignHea dings.* FROM
ReportDesignHea dings WHERE (((ReportID)=@R eportID) AND
((SchID)=@schID ))"
cmdSubjectList = New SqlClient.SqlCo mmand(strSQl,
SqlConnection1)
cmdSubjectList. Parameters.Add( "@ReportID" ,
SqlDbType.Int). Value = Session("Report ID")
cmdSubjectList. Parameters.Add( "@schID", SqlDbType.Int). Value =
Session("id")
Me.SqlConnectio n1.Open()
dr = cmdSubjectList. ExecuteReader()
dr.Read()

strSQl2 = "SELECT SubjectOrder.* FROM SubjectOrder WHERE
(((ReportID)=@R eportID) AND ((SchID)=@schID ))"
cmdTblNameList = New SqlClient.SqlCo mmand(strSQl2,
SqlConnection2)
cmdTblNameList. Parameters.Add( "@ReportID" ,
SqlDbType.Int). Value = Session("Report ID")
cmdTblNameList. Parameters.Add( "@schID", SqlDbType.Int). Value =
Session("id")
Me.SqlConnectio n2.Open()
dr2 = cmdTblNameList. ExecuteReader()
dr2.Read()
arrReportHeadin g.Add(New ChangeHeadings( (dr2.Item("Sub1 ")),
(dr.Item("sub1" ))))
arrReportHeadin g.Add(New ChangeHeadings( (dr2.Item("Sub2 ")),
(dr.Item("sub2" ))))
arrReportHeadin g.Add(New ChangeHeadings( (dr2.Item("Sub3 ")),
(dr.Item("sub3" ))))
arrReportHeadin g.Add(New ChangeHeadings( (dr2.Item("Sub4 ")),
(dr.Item("sub4" ))))
arrReportHeadin g.Add(New ChangeHeadings( (dr2.Item("Sub5 ")),
(dr.Item("sub5" ))))

' etc, etc, etc. to "Sub26" and "sub26"

DataGrid1.DataS ource = arrReportHeadin g
DataGrid1.DataB ind()

dr.Close()
dr2.Close()
cmdSubjectList. Dispose()
cmdTblNameList. Dispose()
Me.SqlConnectio n1.Close()
Me.SqlConnectio n2.Close()
End Function

Public Class ChangeHeadings
Private _FldName As String
Private _FldLabel As String
Public Sub New(ByVal FldName As String, ByVal FldLabel As
String)
_FldName = FldName
_FldLabel = FldLabel
End Sub
Public ReadOnly Property FldName() As String
Get
Return _FldName
End Get
End Property
Public ReadOnly Property FldLabel() As String
Get
Return _FldLabel
End Get
End Property
End Class

Private Sub DataGrid1_EditC ommand(ByVal source As Object, ByVal e
As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.EditC ommand
Me.DataGrid1.Ed itItemIndex = e.Item.ItemInde x
Call FillDatagrid()
Me.DataGrid1.Wi dth = Unit.Pixel(550)
End Sub
Nov 18 '05 #1
0 1337

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

Similar topics

0
4039
by: Faith | last post by:
I found code on www.codeproject.com. Here is a sample it is called DataGridColumnDropDown. I modified it to use the text box when I wanted it to depended on a certain search criteria. Public Class ExtendedSearchFieldValueColumnStyle Inherits DataGridTextBoxColumn Public WithEvents ColumnComboBox As ComboBox Public WithEvents ColumnTextBox As TextBox
5
11186
by: Dalibor Kusic | last post by:
The DataTable contains, for example, only one column of lets say Person class. Person class has three fields, and a constructor that takes a single string and parses it over those three fields. Now, how do I modify the Person class (which interfaces to implement) so I can bind my DataTable to a DataGrid and then add, modify and delete records through it?
0
272
by: anon | last post by:
Hi All, I have an editable datagrid in which one of the fields becomes a Drop dowl list in edit mode....i followed the example in the $ guysfrom rolla article http://www.4guysfromrolla.com/webtech/050801-1.2.shtml however one of them is not really populated from the database, and hence no need of a dataview...i would like to assign an array or arraylist alone to it, however it gives all sorts of errors....the code is as follows
2
5033
by: zambizzi | last post by:
....I can't seem to get my hands on a control I'm loading in an editable datagrid. Here's my datagrid control: <asp:datagrid id="GLRulesGrid" runat="server" autogeneratecolumns="False" oneditcommand="GLRulesGrid_Edit"
1
2684
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting, paginantion or accepting the add and remove item events. What i am observing is that none of the vents are happening... (Sort, page, or item). I am sure I am missing something basic here... Need help... Thanks much
1
4224
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
5
4855
by: Rami | last post by:
Hey, I Tried to bind a DataGrid to an ArrayList, and had 2 problems: 1. The DataGrid shows the Length property of the items instead of their text - how can I change that? 2. After binding, I add new elements to the ArrayList but the DataGrid doesnt refresh's it's view - I have to set the DataSource property of the DataGrid to Nothing and then re bind it to the ArrayList! Isnt there a "pretier" way? Thanks ahead
3
2118
by: Nina | last post by:
Hi there, Is there anyone knows how to make windows form datagrid that is bound to an array editable? How to catch when a cell has been edited? Thank you for your help. Nina
16
2015
by: stojilcoviz | last post by:
I've a datagrid whose datasource is an arraylist object. The arraylist holds many instances of a specific class. I've two questions about this: 1 - Is there a way by which I can obtain a reference to the arraylist item the current row points to? 2 - Is it possible to sort the grid? Many thanks in advance.
0
7957
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
8262
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
8379
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
8020
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
8252
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
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
5839
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
3915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
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

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.