473,651 Members | 2,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Datagrid Problems

Hello

I have hit a major road block when it comes to building my dynamic datagrid. To make a long story short I need a dynamic datagrid because my connection string could change and I need the datagrid to handle that. First I tried to create my datagrid by leaving the auto-generate columns equal to true. This worked fine except that when my user wants to edit a line I do not want them to edit column 1, only column 2. I could not find a way to set this. For this reason I moved to programically creating the whole datagrid. This way I could control the read-only attribute of each cell. However, I am having difficults when it comes time for me to grab the values out of the datagrid for an update. For some reason I am getting a "Specified argument was out of the range of valid values. Parameter name: index" error. Could you please review the below code and explain to me what it is I am doing wrong

*************** *************** *************** *************** *************** ******
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
CreateColumns()
If Not Page.IsPostBack Then
BindDataGrid()
End If
End Sub

Private Sub CreateColumns()
dgProductLocati on.AutoGenerate Columns = False
' Add two columns to the datagrid that only has an edit column in it
Dim dgcPhysLocID As New BoundColumn
dgcPhysLocID.Da taField = "ProductLoc ID"
dgcPhysLocID.He aderText = "ID"
dgcPhysLocID.It emStyle.Width = New Unit(120)
dgcPhysLocID.Re adOnly = True
dgProductLocati on.Columns.Add( dgcPhysLocID)
Dim dgcDescription As New BoundColumn
dgcDescription. DataField = "ProductLocatio nDesc"
dgcDescription. HeaderText = "Descriptio n"
dgcDescription. ItemStyle.Width = New Unit(120)
dgcDescription. ReadOnly = False
dgProductLocati on.Columns.Add( dgcDescription)
End Sub

Private Sub BindDataGrid()
'Creates the dataset that will populate the datagrid
Dim dsPhysLoc As DataSet = ExecuteDataset( ConfigurationSe ttings.AppSetti ngs.Item("sConn "), "GetFBHICSPhysi calLocations", ConfigurationSe ttings.AppSetti ngs.Item("Locat ionID"))
dgProductLocati on.DataSource = dsPhysLoc
dgProductLocati on.DataBind()
End Sub

Private Sub dgProductLocati on_UpdateComman d(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles dgProductLocati on.UpdateComman d
'Local Variable Declarations
Dim strLocID, strProdLocID, strProdLocDesc As String
Dim sCmd As New System.Data.Sql Client.SqlComma nd
'Get and Holds the Value From the DataGrid Item
***
THIS IS WHERE I GET THE ERRO
***
strProdLocID = e.Item.Cells(1) .Text
strProdLocDesc = CType(e.Item.Ce lls(2).Controls (0), TextBox).Text
'...More Code...
End Sub
*************** *************** *************** *************** *************** ********

I would appreciate any help with this as I am at a brick wall right now. Also....once I get past this I will need to know how to convert the second column to a drop down list instead of a textbox in edit mode. It's funny how all of this was so easy with the property builder before I had to start making it dynamic

Thanks In Advance for All Your Hel
Je

Nov 22 '05 #1
0 1282

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

Similar topics

0
1349
by: JP011 | last post by:
Hello I have hit a major road block when it comes to building my dynamic datagrid. To make a long story short I need a dynamic datagrid because my connection string could change and I need the datagrid to handle that. First I tried to create my datagrid by leaving the auto-generate columns equal to true. This worked fine except that when my user wants to edit a line I do not want them to edit column 1, only column 2. I could not find a...
1
2054
by: Mark | last post by:
Hello, I have a database which contains approximately 30 reference tables. I've been looking at building a dynamic datagrid that is updateable, but have run into problems with the Cancel and Update events not firing. After reading several posts about the events not firing, it seems that this may not be the best solution. What would be the best way to handle the updates of the 30 tables? Should I build one page with 30 datagrids and...
1
1587
by: Karine Proot | last post by:
Hello Today I had to build a DataGrid very dynamically <asp:datagrid id="dgTAB" Runat="server" AutoGenerateColumns="False" OnEditCommand="TAB_Edit" OnCancelCommand="TAB_Cancel" OnUpdateCommand="TAB_Update" OnDeleteCommand="TAB_Delete"><Columns><asp:ButtonColumn HeaderText="Delete" Text="Delete" CommandName="Delete" /><asp:EditCommandColumn HeaderText="Edit" EditText="Edit" CancelText="Cancel" UpdateText="Update" /></Columns></asp:datagrid...
0
1692
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a single worksheet into a dataset. I successfully built a dynamic datagrid. And I did successfully bind it to the dataset. Then I added the datagrid control to a PlaceHolder. The first worksheet displays beautifully. The next step is to allow...
4
1692
by: Diego F. | last post by:
Is it possible to generate dynamic reports with Crystal? I'm having problems printing a datagrid because the last line of each page gets cut, so I was thinking of using Crystal. I want to simply pass the datasource of the datagrid and then get the report. Is that possible? -- Regards, Diego F.
8
2007
by: George Meng | last post by:
I got a tough question: The backgroud for this question is: I want to design an application works like a engine. After release, we can still customize a form by adding a button, and source code for the button. (This is done by the form itself, not by using VS.Net) (button and source code should be a record in database, these information should be retrieve from database when the form shows up) What I want is:
3
13738
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
3
1433
by: Bart Van Hemelen | last post by:
Here's what I'm trying to accomplish: I get a number from another page that indicates the number of members. The page I want to build -- actually it's not a page, but a UserControl -- needs to display a form with several types of input fields for each of those members: regular text fields, a dropdown and Infragistics' WebDateChooser. The point is that someone inputs thinsg like name, date of birth etc for each of the members, which...
0
2906
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
2
2702
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous 1 2 3 4 5 ... Next Last >> I have achieved the first/previous/next/last buttons quite easily as follows in the ASPX (1.1) page:
0
8357
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...
1
8465
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
7298
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
6158
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
5612
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
4144
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...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
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.