Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > asp.net datagrid textbox blank in edit mode or "not set to an instance" error

Reply
Thread Tools

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

 
 
jason@cyberpine.com
Guest
Posts: n/a
 
      08-23-2005
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!

 
Reply With Quote
 
 
 
 
jason@cyberpine.com
Guest
Posts: n/a
 
      08-24-2005
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?

 
Reply With Quote
 
 
 
 
Trevor Benedict R
Guest
Posts: n/a
 
      10-22-2005
Dim xNote as TextBox = cType(e.Item.FindControl("xNotes"), TextBox)
should work. Try this. e.Item is a reference to the row that is being called
to be editied.

Regards,

Trevor Benedict R
MCSD


<> wrote in message
news: oups.com...
> 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?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
in datagrid control , how can i change the width of textbox in edit mode (on <asp:BoundColumn> ) ? Yunus Emre ALPÖZEN [MCAD.NET] ASP .Net 1 05-02-2005 05:38 PM
Would like to load a datagrid already in edit mode instead of having the user click the edit button Frank Kurka ASP .Net Datagrid Control 8 04-29-2005 09:33 AM
Set the width of the edit textbox after clicking on Edit link in datagrid... Sharon McCarty ASP .Net Datagrid Control 0 11-24-2004 06:41 PM
Datagrid Edit mode TextBox Size Brian Rupert ASP .Net Web Controls 1 09-15-2004 07:41 AM
TextBox and DropDownList in Datagrid Edit mode =?Utf-8?B?TmV3VG9Eb3ROZXQ=?= ASP .Net 2 02-09-2004 07:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57