469,912 Members | 1,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,912 developers. It's quick & easy.

asp.net datagrid textbox blank in edit mode or "not set to an instance" error

I've seen a few posts on this issue, but no clear solutions.

I have a mulitiline textbox inside a datagrid.

I use TemplateColumn to define as multiline with 3 rows.

I have other field types like drop downs that have no issue displaying
last values in edit mode with seemingly more complicated code.

when I attempt to find my textbox with

Dim ddlxnotes2 As textbox =
UserGrid.Items(e.Item.ItemIndex).FindControl("xnot es")
ddlxnotes2.text = ctype(e.item.FindControl("xnotes"), TextBox).text

I get error:
Object reference not set to an instance of an object

I've tried to simply enter the number

ddlxnotes2.text = e.Item.Cells(5).text

but that produces a blank field in edit mode. When I change the feild
number (from 5) to other fields numbers it does load their set value.

I tried removing multiline and rows=3 from the asp:textbox tag, but the
error persist and the field is blank. I am sure it's field number 5 on
the datagrid as it's the last field, 4 works and 6 produces an out of
range.
here's the complete field TAG

asp:TemplateColumn HeaderText="Notes">
<itemstyle width=200 />
<ItemTemplate >
<asp:Label runat="server" Text='<%# Container.DataItem("xnotes") %>'
ID="Lblnotes"/>
</ItemTemplate>
<EditItemTemplate>
<asp:textbox textmode=multiline rows=3 width=400 runat="server"
id="xnotes">
</asp:textbox>
</EditItemTemplate>
</asp:TemplateColumn>
Thanks in advance for any help or information!

Nov 19 '05 #1
1 1572
GOING NUTS...

' this does not work - one of many attempts
Dim ddlxnotes As TextBox =
Usergrid.Items(e.Item.ItemIndex).FindControl("xnot es")
ddlxnotes.text =
ctype(Usergrid.Items(e.Item.ItemIndex).FindControl ("xnotes"),textbox).text
' this works but reall need cell 5 which shows up blank
' Dim ddlxnotes As TextBox =
Usergrid.Items(e.Item.ItemIndex).FindControl("xnot es")
' ddlxnotes.text = e.Item.cells(4).text

' this works
' Dim ddlxnotes As TextBox =
Usergrid.Items(e.Item.ItemIndex).FindControl("xnot es")
' ddlxnotes.text = "x"
<asp:TemplateColumn HeaderText="Notes">
<itemstyle width=400 />
<ItemTemplate >
<asp:Label runat="server" Text='<%# Container.DataItem("xnotes") %>'
ID="Lblnotes"/>
</ItemTemplate>
<EditItemTemplate>
<asp:textbox textmode=multiline rows=3 width=400 runat="server"
id="xnotes">
</asp:textbox>
</EditItemTemplate>
</asp:TemplateColumn>
Everything else on the datagrid , including so Edititemtemplates for
dropdowns displays the last value in edit mode....
What on earth am I doing wrong?

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Brad Simon | last post: by
5 posts views Thread by Patrick.O.Ige | last post: by
1 post views Thread by tshad | last post: by
9 posts views Thread by A P | last post: by
11 posts views Thread by Anil Gupte/iCinema.com | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.