Thanks, that works. In the mean time I also discovered that the following
works
dim tb as System.Web.UI.WebControls.TextBox
tb = dgMyGrid.Items(i).Cells(3).Controls(1)
myStr = tb.Text
I'm not sure how all of this is related. I looked around the VS Help and
found a lot of info about constructing you own templates, etc but not much
about simply using what's already there. If you know a good link I'd
appreciate it. Preferably a VS designer example and not one heavy on html.
Thanks
"Jos" wrote:
> jcriv wrote:
> > Hi,
> > I have a datagrid on a webform and I also have an OK Button. I
> > designed the datagrid in Visual Studio. The dg has 3 'databound'
> > coulmns and 3 template columns. I used the drop down tool 'Edit
> > Template' to 'Item Template' to a TextBox with an initial text value.
> >
> > When I run the program I bind the grid to a dataset which has 3
> > columns. The grid displays just fine. My first three columns have
> > the data from my dataset and the last three columns have my initial
> > text value in the text boxes.
> >
> > What I want to do is to let a user tab thru the template textboxes
> > and make entries and when done press the OK button on the form. I
> > then want to retieve the values the user entered in the template
> > textboxes.
> >
> > In my 'code behind' I have code the looks like
> >
> > For i = 0 to dsMyDataSet.Tables(0).Rows.Count - 1
> >
> > strText = dgMyGrid.Items(i).Cells(3).Text
> >
> > Next
> >
> > But, the text values I get in all cases is "" (blank). I don't get
> > whet the user types in nor do I get my initial default value. Note:
> > For Cells (0,1,2) I do get back the databound values. Cells(3)
> > would be the first 'Template' cell.
> >
> > Any idea what I might be doing wrong here?
> >
> > Thanks
>
> Cells(3).Text would be the Text value of the table cell, not
> the Text value of the TextBox.
>
> Use:
> strText = CType(dgMyGrid.Items(i).FindControl("IDOfTextBox") ,TextBox).Text
>
> where IDOfTextBox is the ID that you assigned to the TextBox.
>
> --
>
> Jos
>
>
>
|