Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > access controls inside formview inside loginview

Reply
Thread Tools

access controls inside formview inside loginview

 
 
wikkiwikkiwaa
Guest
Posts: n/a
 
      08-03-2006
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 simple. a label control would
be:
Label label1 = (Label)loginview1.FindControl("nameoflabel");
then i get to the data that was bound to that control.

i cannot figure out how to get to the formview1 controls. the formview1
defaults to the itemtemplate, but also has a edititem and iteminsert
templates. the labels i am trying to get to inside formview1 are
ZIPLabel, ADDR1Label, and CITYLabel. i cannot seem to get the syntax to
get to them correct.

i'm also not sure at what point they have been created and that i
really have access to them. for example.

i tried to get to them through one of the events formview1_DataBound,
but they don't seem to exist yet.

i'm missing something fundamental here and i'm starting to get
frustrated. any help would be appreciated.

thank you for your time

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Y2xpY2tvbg==?=
Guest
Posts: n/a
 
      08-04-2006
So long as the controls in the FormView are named uniquely within the
formview, not just within the Template then it should be no problem, so just
have to call two sets of FindControl

e.g. to access a textbox that is within the formview:

FormView MyFormView = (FormView)LoginView1.FindControl("FormViewID~");

TextBox MyTextBox = (TextBox)MyFormView.FindControl("TextBoxID");

MyTextBox.Text = "Some Words";

However if you have a text box in the insert item template and the edit item
template with the same ID then it will generate an error. Also if you try to
retreive a control from the edit item template and the FormView is not in
edit mode then you will probably get the object reference not set to instance
of an object error.


"wikkiwikkiwaa" wrote:

> 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 simple. a label control would
> be:
> Label label1 = (Label)loginview1.FindControl("nameoflabel");
> then i get to the data that was bound to that control.
>
> i cannot figure out how to get to the formview1 controls. the formview1
> defaults to the itemtemplate, but also has a edititem and iteminsert
> templates. the labels i am trying to get to inside formview1 are
> ZIPLabel, ADDR1Label, and CITYLabel. i cannot seem to get the syntax to
> get to them correct.
>
> i'm also not sure at what point they have been created and that i
> really have access to them. for example.
>
> i tried to get to them through one of the events formview1_DataBound,
> but they don't seem to exist yet.
>
> i'm missing something fundamental here and i'm starting to get
> frustrated. any help would be appreciated.
>
> thank you for your time
>
>

 
Reply With Quote
 
 
 
 
wikkiwikkiwaa
Guest
Posts: n/a
 
      08-09-2006
thank you so much for your help. appreciate you taking the time to
check out my problem.

clickon wrote:
> So long as the controls in the FormView are named uniquely within the
> formview, not just within the Template then it should be no problem, so just
> have to call two sets of FindControl
>
> e.g. to access a textbox that is within the formview:
>
> FormView MyFormView = (FormView)LoginView1.FindControl("FormViewID~");
>
> TextBox MyTextBox = (TextBox)MyFormView.FindControl("TextBoxID");
>
> MyTextBox.Text = "Some Words";
>
> However if you have a text box in the insert item template and the edit item
> template with the same ID then it will generate an error. Also if you try to
> retreive a control from the edit item template and the FormView is not in
> edit mode then you will probably get the object reference not set to instance
> of an object error.
>
>
> "wikkiwikkiwaa" wrote:
>
> > 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 simple. a label control would
> > be:
> > Label label1 = (Label)loginview1.FindControl("nameoflabel");
> > then i get to the data that was bound to that control.
> >
> > i cannot figure out how to get to the formview1 controls. the formview1
> > defaults to the itemtemplate, but also has a edititem and iteminsert
> > templates. the labels i am trying to get to inside formview1 are
> > ZIPLabel, ADDR1Label, and CITYLabel. i cannot seem to get the syntax to
> > get to them correct.
> >
> > i'm also not sure at what point they have been created and that i
> > really have access to them. for example.
> >
> > i tried to get to them through one of the events formview1_DataBound,
> > but they don't seem to exist yet.
> >
> > i'm missing something fundamental here and i'm starting to get
> > frustrated. any help would be appreciated.
> >
> > thank you for your time
> >
> >


 
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
LoginView cant find controls... Seb ASP .Net 2 05-13-2008 01:40 PM
Can't access controls inside a formView Andy B ASP .Net 4 01-16-2008 02:01 PM
Embedding Controls in LoginView removes references =?Utf-8?B?am1obWFpbmU=?= ASP .Net 3 12-27-2006 08:31 AM
Can't access webpage's controls from the code-behind file after putting it in a <asp:LoginView/> Jack ASP .Net Web Controls 1 07-03-2006 01:54 PM
How to access asp controls inside a loginview LLars ASP General 2 02-14-2006 07:52 AM



Advertisments