473,378 Members | 1,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

FormView - FindControl

Hi
I'm having trouble trying to use FindControl with a FormView, but can't seem
to find what I'm doing wrong....

I have a TextBox in my ItemTemplate, and I want to assign a value to it, in
code...

I'm trying:

((TextBox)FormView1.FindControl("TextBox1")).Text = "Sample value";

The error reported is 'Object reference not set to an instance of an
object.'

Any ideas?

Thanks
Feb 25 '06 #1
6 2928
Paul where are you doing that?
Patrick
**It seems it can't find the control
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:UH******************@fe1.news.blueyonder.co.u k...
Hi
I'm having trouble trying to use FindControl with a FormView, but can't
seem to find what I'm doing wrong....

I have a TextBox in my ItemTemplate, and I want to assign a value to it,
in code...

I'm trying:

((TextBox)FormView1.FindControl("TextBox1")).Text = "Sample value";

The error reported is 'Object reference not set to an instance of an
object.'

Any ideas?

Thanks

Feb 25 '06 #2
I've tried it in a few places, prerender, load, databinding etc.

No joy anywhere.

Has anyone actually managed to do this in C#??

Thanks

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Paul where are you doing that?
Patrick
**It seems it can't find the control
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:UH******************@fe1.news.blueyonder.co.u k...
Hi
I'm having trouble trying to use FindControl with a FormView, but can't
seem to find what I'm doing wrong....

I have a TextBox in my ItemTemplate, and I want to assign a value to it,
in code...

I'm trying:

((TextBox)FormView1.FindControl("TextBox1")).Text = "Sample value";

The error reported is 'Object reference not set to an instance of an
object.'

Any ideas?

Thanks


Feb 25 '06 #3
This may help.

protected override void OnInit(EventArgs e)
{
FormView1.ItemCreated += new
EventHandler(FormView1_ItemCreated);
base.OnInit(e);
}

void FormView1_ItemCreated(object sender, EventArgs e)
{
TextBox t = (TextBox)FormView1.Row.FindControl("TextBox1");
t.Text = "foo";
}

Chris

Feb 25 '06 #4
Doh - Fixed it...

Thanks anyway

Paul

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:lX*******************@fe2.news.blueyonder.co. uk...
I've tried it in a few places, prerender, load, databinding etc.

No joy anywhere.

Has anyone actually managed to do this in C#??

Thanks

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Paul where are you doing that?
Patrick
**It seems it can't find the control
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:UH******************@fe1.news.blueyonder.co.u k...
Hi
I'm having trouble trying to use FindControl with a FormView, but can't
seem to find what I'm doing wrong....

I have a TextBox in my ItemTemplate, and I want to assign a value to it,
in code...

I'm trying:

((TextBox)FormView1.FindControl("TextBox1")).Text = "Sample value";

The error reported is 'Object reference not set to an instance of an
object.'

Any ideas?

Thanks



Feb 25 '06 #5
What was it Paul?

I get the same error.

Cheers,

Nick

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:k7*******************@fe2.news.blueyonder.co. uk...
Doh - Fixed it...

Thanks anyway

Paul

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:lX*******************@fe2.news.blueyonder.co. uk...
I've tried it in a few places, prerender, load, databinding etc.

No joy anywhere.

Has anyone actually managed to do this in C#??

Thanks

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Paul where are you doing that?
Patrick
**It seems it can't find the control
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:UH******************@fe1.news.blueyonder.co.u k...
Hi
I'm having trouble trying to use FindControl with a FormView, but can't
seem to find what I'm doing wrong....

I have a TextBox in my ItemTemplate, and I want to assign a value to
it, in code...

I'm trying:

((TextBox)FormView1.FindControl("TextBox1")).Text = "Sample value";

The error reported is 'Object reference not set to an instance of an
object.'

Any ideas?

Thanks



Feb 25 '06 #6
Hi Nick,

I've emailed you.

Cheers
"Nick" <ni**********@gmail.com> wrote in message
news:O%***************@TK2MSFTNGP14.phx.gbl...
What was it Paul?

I get the same error.

Cheers,

Nick

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:k7*******************@fe2.news.blueyonder.co. uk...
Doh - Fixed it...

Thanks anyway

Paul

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:lX*******************@fe2.news.blueyonder.co. uk...
I've tried it in a few places, prerender, load, databinding etc.

No joy anywhere.

Has anyone actually managed to do this in C#??

Thanks

"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Paul where are you doing that?
Patrick
**It seems it can't find the control
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:UH******************@fe1.news.blueyonder.co.u k...
> Hi
> I'm having trouble trying to use FindControl with a FormView, but
> can't seem to find what I'm doing wrong....
>
> I have a TextBox in my ItemTemplate, and I want to assign a value to
> it, in code...
>
> I'm trying:
>
> ((TextBox)FormView1.FindControl("TextBox1")).Text = "Sample value";
>
>
>
> The error reported is 'Object reference not set to an instance of an
> object.'
>
>
>
> Any ideas?
>
>
>
> Thanks
>
>



Feb 26 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sck10 | last post by:
Hello, I am trying to bind an arraylist to a FormView DropDownList control in the PreRender state. The error that I get is the following: Databinding methods such as Eval(), XPath(), and...
2
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
2
by: wikkiwikkiwaa | last post by:
hello, i am trying to access controls inside my formview1 nested inside loginview1. you cannot access the formview1 unless you are properly logged in. for loginview1, that seems to be fairly...
1
by: Paul | last post by:
Hello: I have an aspx page with a Formview and a Gridview on it. I have a dropdownlist control which I want to bind to both the Formview and the Gridview. I put the dropdownlist in the...
3
by: YMPN | last post by:
Hi Everyone, I'm deen from Riyadh. Please do help me with some problem i have. I have this formview control setup to recieved inputs from user (textbox, dropdownlist, others). After...
3
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText"...
1
by: Trev | last post by:
Hi, I'm hoping that someone in this group can shed some light on an issue I'm having with a Formview. I have a Web User Control (.ascx) with a Formview. The Formview contains 2 Multiviews,...
6
by: Chris | last post by:
I want do my insert to a database using a formview bound to an objectdatasource. I also want to upload a file. I'm quite new to and this is just test code but Is there any way I can pass the file...
3
by: J055 | last post by:
Hi I can't figure out what the difference is here. Sometimes I have a simple FormView control in a page and I can use the FormView.FindControl method to get a Label or TextBox with in it during...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.