Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Use FindControl for HMTL control in Datagrid

Reply
Thread Tools

Use FindControl for HMTL control in Datagrid

 
 
Sid
Guest
Posts: n/a
 
      11-10-2003
Hi,

I am trying to use the FindControl method to find a HTML
Select control I have in my Datagrid. The syntax I am
using is

Dim obj As HTMLSelect
Dim str As String

obj = E.Item.FindControl("controlname")
str = obj.Value

Only thing is this gives an error saying 'object is not
set to a reference of an object', does anyone know if this
is even possible?

Thanks

Sid

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      11-10-2003
Are you using this in ItemCreated or ItemDataBound? If yes, do you check
ItemType property that the item is Item or AlternatingItem?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Sid" <(E-Mail Removed)> wrote in message
news:09bf01c3a7a4$27961c10$(E-Mail Removed)...
> Hi,
>
> I am trying to use the FindControl method to find a HTML
> Select control I have in my Datagrid. The syntax I am
> using is
>
> Dim obj As HTMLSelect
> Dim str As String
>
> obj = E.Item.FindControl("controlname")
> str = obj.Value
>
> Only thing is this gives an error saying 'object is not
> set to a reference of an object', does anyone know if this
> is even possible?
>
> Thanks
>
> Sid
>



 
Reply With Quote
 
 
 
 
Sid
Guest
Posts: n/a
 
      11-10-2003
Hi, Thanks for replying, I am using this in the
EditItemTemplate and it is being used in the UpdateItem
command.


>-----Original Message-----
>Are you using this in ItemCreated or ItemDataBound? If

yes, do you check
>ItemType property that the item is Item or

AlternatingItem?
>
>--
>Teemu Keiski
>MCP, Microsoft MVP (ASP.NET), AspInsiders member
>ASP.NET Forum Moderator, AspAlliance Columnist
>
>"Sid" <(E-Mail Removed)> wrote in

message
>news:09bf01c3a7a4$27961c10$(E-Mail Removed)...
>> Hi,
>>
>> I am trying to use the FindControl method to find a HTML
>> Select control I have in my Datagrid. The syntax I am
>> using is
>>
>> Dim obj As HTMLSelect
>> Dim str As String
>>
>> obj = E.Item.FindControl("controlname")
>> str = obj.Value
>>
>> Only thing is this gives an error saying 'object is not
>> set to a reference of an object', does anyone know if

this
>> is even possible?
>>
>> Thanks
>>
>> Sid
>>

>
>
>.
>

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      11-10-2003
Ok,

can you show an example of the declarative (aspx) syntax you have and a bit
more of the code?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Sid" <(E-Mail Removed)> wrote in message
news:004801c3a7b0$a4c51d10$(E-Mail Removed)...
> Hi, Thanks for replying, I am using this in the
> EditItemTemplate and it is being used in the UpdateItem
> command.
>
>
> >-----Original Message-----
> >Are you using this in ItemCreated or ItemDataBound? If

> yes, do you check
> >ItemType property that the item is Item or

> AlternatingItem?
> >
> >--
> >Teemu Keiski
> >MCP, Microsoft MVP (ASP.NET), AspInsiders member
> >ASP.NET Forum Moderator, AspAlliance Columnist
> >
> >"Sid" <(E-Mail Removed)> wrote in

> message
> >news:09bf01c3a7a4$27961c10$(E-Mail Removed)...
> >> Hi,
> >>
> >> I am trying to use the FindControl method to find a HTML
> >> Select control I have in my Datagrid. The syntax I am
> >> using is
> >>
> >> Dim obj As HTMLSelect
> >> Dim str As String
> >>
> >> obj = E.Item.FindControl("controlname")
> >> str = obj.Value
> >>
> >> Only thing is this gives an error saying 'object is not
> >> set to a reference of an object', does anyone know if

> this
> >> is even possible?
> >>
> >> Thanks
> >>
> >> Sid
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
Sid
Guest
Posts: n/a
 
      11-11-2003
No problem, this is how my columns are declared in the
datagrid:

<asp:TemplateColumn HeaderText="Heading">
<ITEMTEMPLATE>
<table>
<tbody>
<tr>
<td>
<select name="ddlCountry">
<option value="Wales"
selected="selected">Wales</option>
</select>
</td>
</tr>
</tbody>
</table>
</ITEMTEMPLATE>
<EDITITEMTEMPLATE>
<table>
<tbody>
<tr>
<td>
<select name="ddlCountry">
<option value="Wales"
selected="selected">Wales</option>
</select>
</td>
</tr>
</tbody>
</table>
</EDITITEMTEMPLATE>
</asp:TemplateColumn>

And then I call this in the EditItemCommand:

sub doEdit(sender as object, e as _
Datagridcommandeventargs)

Dim obj as HTMLSelect
dim myStr as string
obj = CType(e.Item.FindControl _
("ddlCountry"), HTMLSelect)

myStr = obj.Value ##Errors here

end Sub


Hope this helps?

>-----Original Message-----
>Ok,
>
>can you show an example of the declarative (aspx) syntax

you have and a bit
>more of the code?
>
>--
>Teemu Keiski
>MCP, Microsoft MVP (ASP.NET), AspInsiders member
>ASP.NET Forum Moderator, AspAlliance Columnist
>
>"Sid" <(E-Mail Removed)> wrote in

message
>news:004801c3a7b0$a4c51d10$(E-Mail Removed)...
>> Hi, Thanks for replying, I am using this in the
>> EditItemTemplate and it is being used in the UpdateItem
>> command.
>>
>>
>> >-----Original Message-----
>> >Are you using this in ItemCreated or ItemDataBound? If

>> yes, do you check
>> >ItemType property that the item is Item or

>> AlternatingItem?
>> >
>> >--
>> >Teemu Keiski
>> >MCP, Microsoft MVP (ASP.NET), AspInsiders member
>> >ASP.NET Forum Moderator, AspAlliance Columnist
>> >
>> >"Sid" <(E-Mail Removed)> wrote in

>> message
>> >news:09bf01c3a7a4$27961c10$(E-Mail Removed)...
>> >> Hi,
>> >>
>> >> I am trying to use the FindControl method to find a

HTML
>> >> Select control I have in my Datagrid. The syntax I am
>> >> using is
>> >>
>> >> Dim obj As HTMLSelect
>> >> Dim str As String
>> >>
>> >> obj = E.Item.FindControl("controlname")
>> >> str = obj.Value
>> >>
>> >> Only thing is this gives an error saying 'object is

not
>> >> set to a reference of an object', does anyone know if

>> this
>> >> is even possible?
>> >>
>> >> Thanks
>> >>
>> >> Sid
>> >>
>> >
>> >
>> >.
>> >

>
>
>.
>

 
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
HMTL Bob B Computer Support 8 04-14-2007 02:45 AM
any charitable hmtl guru needed!! cassiadenton@gmail.com HTML 31 12-07-2006 08:22 AM
Modify the HMTL generated in a user control David ASP .Net Building Controls 1 07-13-2005 09:07 AM
study HMTL Simon Spencer HTML 3 10-12-2004 08:48 PM
Newby question: how convert hmtl -> jpg? Nico Fluitsma HTML 10 11-09-2003 09:33 PM



Advertisments