[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Insert rows in a DataGrid - get to added row's info?

(Jonathon)

12/25/2002 10:26:00 PM

I have a question about a post from Anand Hegde

From Anand Hegde (anandhegde@onlinemicrosoft.com)
Subject: Re: HOWTO: A new way to insert rows in a DataGrid
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: 2002-03-26 15:44:45 PST



In it you explained more about how to add a new record to a datagrid
using the following syntax:

DataGrid1.Controls(0).Controls.AddAt_
(Me.DataGrid1.SelectedIndex + 3, dgitem)

That works wonderfully but how do you get to the data after entering
in information.

I have a textbox in one of the TableCells that I'm adding to the
datagrid.

Dim mycell3 As New TableCell()
Dim myTextbox3 As New TextBox()

myTextbox3.Width = System.Web.UI.WebControls.Unit.Pixel(75)
mycell3.Controls.Add(myTextbox3)
dgitem.Cells.Add(mycell3)

It displays fine.

If I refer to the row number for the insert row, it references the row
after the inserted item.
If I refer to the row before the inserted row, it references the row
before the inserted item.
I can't seem to refer to the row I added.

I'm using the following code to work with the information in the other
rows.

Dim tb As TextBox
tb = CType(DataGrid1.Items(2).Cells(2).Controls(1), TextBox)
PlanDate = tb.Text

As long as I'm refering to a row that was in the datagrid from when it
was bound to the dataset, I can reference the textbox.

I am unable to get the information out of the inserted row.

Help!!!

Thanks for any help you can give me,
1 Answer

(Jonathon)

12/25/2002 10:28:00 PM

0

I've gone a different route. Instead of adding the new row directly
into the datagrid, I am now adding a blank row into the dataset. I
didn't want to do it that way but I had no choice.

I'm still interested to know how to reference the info in the added
row when the row is added directly to the datagrid (not the the
datasource).

Thanks for any advice in advance,

Jonathon