Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > accesing controls in code-behind

Reply
Thread Tools

accesing controls in code-behind

 
 
R.A.M.
Guest
Posts: n/a
 
      12-20-2006
Hello,
I am learning ASP.NET.
On .aspx page I have a data-list with text-box that I would like to read
during line modification.

<aspataList ...
OnEditCommand="Sample_Edit" >
...
<EditItemTemplate>
...
<asp:TextBox ID="SampleEdit" runat="server" />
...
</EditItemTemplate>
...
</aspataList>

In code-behind I have:

protected void Sample_Edit(object sender, DataListCommandEventArgs e)
{
...
string Sample = ((TextBox)e.Item.FindControl("SampleEdit")).Text;
// here problem
...
}

The problem is that although e.Item is fine, FindControl returns null.
Could you help me to programme it correctly?
Thank you !!!
/RAM/


 
Reply With Quote
 
 
 
 
R.A.M.
Guest
Posts: n/a
 
      12-20-2006
I have also tried this way:
Sample =
((TextBox)SampleDataList.Items[e.Item.ItemIndex].FindControl("SampleEdit")).Text;

and this way:
Sample =
((TextBox)SampleDataList.SelectedItem.FindControl( "SampleEdit")).Text;

but it doesn't work, either.

Użytkownik "R.A.M." <(E-Mail Removed)> napisał w wiadomości
news:emav46$aas$(E-Mail Removed)...
> Hello,
> I am learning ASP.NET.
> On .aspx page I have a data-list with text-box that I would like to read
> during line modification.
>
> <aspataList ...
> OnEditCommand="Sample_Edit" >
> ...
> <EditItemTemplate>
> ...
> <asp:TextBox ID="SampleEdit" runat="server" />
> ...
> </EditItemTemplate>
> ...
> </aspataList>
>
> In code-behind I have:
>
> protected void Sample_Edit(object sender, DataListCommandEventArgs e)
> {
> ...
> string Sample = ((TextBox)e.Item.FindControl("SampleEdit")).Text;
> // here problem
> ...
> }
>
> The problem is that although e.Item is fine, FindControl returns null.
> Could you help me to programme it correctly?
> Thank you !!!
> /RAM/
>
>



 
Reply With Quote
 
 
 
 
R.A.M.
Guest
Posts: n/a
 
      12-20-2006
OK, I solved. SampleEdit is not accessible before edit mode set.

Użytkownik "R.A.M." <(E-Mail Removed)> napisał w wiadomości
news:embpqv$2fq$(E-Mail Removed)...
>I have also tried this way:
> Sample =
> ((TextBox)SampleDataList.Items[e.Item.ItemIndex].FindControl("SampleEdit")).Text;
>
> and this way:
> Sample =
> ((TextBox)SampleDataList.SelectedItem.FindControl( "SampleEdit")).Text;
>
> but it doesn't work, either.
>
> Użytkownik "R.A.M." <(E-Mail Removed)> napisał w wiadomości
> news:emav46$aas$(E-Mail Removed)...
>> Hello,
>> I am learning ASP.NET.
>> On .aspx page I have a data-list with text-box that I would like to read
>> during line modification.
>>
>> <aspataList ...
>> OnEditCommand="Sample_Edit" >
>> ...
>> <EditItemTemplate>
>> ...
>> <asp:TextBox ID="SampleEdit" runat="server" />
>> ...
>> </EditItemTemplate>
>> ...
>> </aspataList>
>>
>> In code-behind I have:
>>
>> protected void Sample_Edit(object sender, DataListCommandEventArgs e)
>> {
>> ...
>> string Sample = ((TextBox)e.Item.FindControl("SampleEdit")).Text;
>> // here problem
>> ...
>> }
>>
>> The problem is that although e.Item is fine, FindControl returns null.
>> Could you help me to programme it correctly?
>> Thank you !!!
>> /RAM/
>>
>>

>
>



 
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
help with Accesing pix 506 Tomas Cisco 10 05-13-2004 02:29 PM
Structural VHDL - Accesing signals of instances Valentin Tihomirov VHDL 2 11-02-2003 12:08 PM
Accesing embedded controls?? ozgur develioglu ASP .Net Building Controls 0 07-21-2003 06:57 AM
Accesing embedded controls ozgur develioglu ASP .Net Web Controls 0 07-21-2003 06:56 AM
Accesing embedded controls ozgur develioglu ASP .Net Datagrid Control 0 07-21-2003 06:56 AM



Advertisments