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

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="True">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
</Columns>
</asp:datagrid>

CODE BEHIND:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Me.SqlConnection1.ConnectionString = Global.ConnectionString
Me.SqlConnection2.ConnectionString = Global.ConnectionString

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

End Sub

Function FillDatagrid()
Dim arrReportHeading As New ArrayList()
Dim strSQl As String
Dim strSQl2 As String
Dim cmdSubjectList As SqlClient.SqlCommand
Dim cmdTblNameList As SqlClient.SqlCommand

Dim dr As SqlClient.SqlDataReader
Dim dr2 As SqlClient.SqlDataReader

strSQl = "SELECT ReportDesignHeadings.* FROM
ReportDesignHeadings WHERE (((ReportID)=@ReportID) AND
((SchID)=@schID))"
cmdSubjectList = New SqlClient.SqlCommand(strSQl,
SqlConnection1)
cmdSubjectList.Parameters.Add("@ReportID",
SqlDbType.Int).Value = Session("ReportID")
cmdSubjectList.Parameters.Add("@schID", SqlDbType.Int).Value =
Session("id")
Me.SqlConnection1.Open()
dr = cmdSubjectList.ExecuteReader()
dr.Read()

strSQl2 = "SELECT SubjectOrder.* FROM SubjectOrder WHERE
(((ReportID)=@ReportID) AND ((SchID)=@schID))"
cmdTblNameList = New SqlClient.SqlCommand(strSQl2,
SqlConnection2)
cmdTblNameList.Parameters.Add("@ReportID",
SqlDbType.Int).Value = Session("ReportID")
cmdTblNameList.Parameters.Add("@schID", SqlDbType.Int).Value =
Session("id")
Me.SqlConnection2.Open()
dr2 = cmdTblNameList.ExecuteReader()
dr2.Read()
arrReportHeading.Add(New ChangeHeadings((dr2.Item("Sub1")),
(dr.Item("sub1"))))
arrReportHeading.Add(New ChangeHeadings((dr2.Item("Sub2")),
(dr.Item("sub2"))))
arrReportHeading.Add(New ChangeHeadings((dr2.Item("Sub3")),
(dr.Item("sub3"))))
arrReportHeading.Add(New ChangeHeadings((dr2.Item("Sub4")),
(dr.Item("sub4"))))
arrReportHeading.Add(New ChangeHeadings((dr2.Item("Sub5")),
(dr.Item("sub5"))))

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

DataGrid1.DataSource = arrReportHeading
DataGrid1.DataBind()

dr.Close()
dr2.Close()
cmdSubjectList.Dispose()
cmdTblNameList.Dispose()
Me.SqlConnection1.Close()
Me.SqlConnection2.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_EditCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand
Me.DataGrid1.EditItemIndex = e.Item.ItemIndex
Call FillDatagrid()
Me.DataGrid1.Width = Unit.Pixel(550)
End Sub
Nov 18 '05 #1
0 1321

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

Similar topics

0
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...
5
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. ...
0
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...
2
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"...
1
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,...
1
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...
5
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...
3
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.