Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > EditItemTemplate FindControls

Reply
Thread Tools

EditItemTemplate FindControls

 
 
JJ
Guest
Posts: n/a
 
      12-30-2004
Hi,

What I am trying to do is save the values from the ItemTemplate textboxs,
which I already do and when I go into Edit mode insert values into textboxs
in EditItemTemplate. Inserting values into EditItemTemplate is where I get
the "obj ref not set error". It happens because the event I use now which is
in the OnEditCOmmand for datagrid can't find the controls in
EditItemTemplate. So where should I put the FindControl statements in order
to have this work?

Thanks,

JJ
 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      01-04-2005
> What I am trying to do is save the values from the ItemTemplate textboxs,
> which I already do and when I go into Edit mode insert values into textboxs
> in EditItemTemplate. Inserting values into EditItemTemplate is where I get
> the "obj ref not set error". It happens because the event I use now which is
> in the OnEditCOmmand for datagrid can't find the controls in
> EditItemTemplate. So where should I put the FindControl statements in order
> to have this work?


If I understand you correctly, you want to make sure that the values in
the ItemTemplate are in the TextBoxes in the EditItemTemplate, correct?

Don't do this programmatically, but rather declaratively. That is,
imagine in your ASPX page you have:

<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Foo") %>
</ItemTemplate>
<EditItemTemplate>
...
</EditItemTemplate>
</asp:TemplateColumn>

In your TextBox in your EditItemTemplate set the Text property to <%#
DataBinder.Eval(Container.DataItem, "Foo") %>, like:

<asp:TextBox runat='server' ... Text='<%#
DataBinder.Eval(Container.DataItem, "Foo") %>' ... />

hth

--

Scott Mitchell [ASP.NET MVP]
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com/ScottMitchell
 
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
Using FindControls and Type casting =?Utf-8?B?TWljaGFlbA==?= ASP .Net 2 04-26-2006 06:44 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
CustomValidator in the EditItemTemplate of a DataGrid Dave ASP .Net 1 10-31-2003 07:10 AM
Datalist EditItemTemplate SStory ASP .Net 0 08-18-2003 11:01 PM
datagrid edititemtemplate for dates Trevor Hartman ASP .Net 0 07-16-2003 06:46 PM



Advertisments