473,396 Members | 2,018 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,396 software developers and data experts.

Use FindControl for HMTL control in Datagrid

Sid
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

Nov 17 '05 #1
4 3513
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" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
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

Nov 17 '05 #2
Sid
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 checkItemType property that the item is Item or AlternatingItem?
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Sid" <an*******@discussions.microsoft.com> wrote in messagenews:09****************************@phx.gbl...
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

.

Nov 17 '05 #3
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" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
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" <an*******@discussions.microsoft.com> wrote in

message
news:09****************************@phx.gbl...
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

.

Nov 17 '05 #4
Sid
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 bitmore of the code?

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

"Sid" <an*******@discussions.microsoft.com> wrote in messagenews:00****************************@phx.gbl...
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" <an*******@discussions.microsoft.com> wrote in

message
>news:09****************************@phx.gbl...
>> 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
>>
>
>
>.
>

.

Nov 17 '05 #5

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

Similar topics

0
by: George Durzi | last post by:
cross posted in datagrid group. Inside <columns/> in my datagrid, I have the following template column <asp:templatecolumn HeaderText="To Be Completed By"> <itemtemplate> <asp:Label...
1
by: Mike Speak | last post by:
On my page_load, I am populating a Datagrid through the normal manner (which works) before attempting to pick out the items in one column to use in another part of my page. This is all within...
10
by: Joe | last post by:
Hi, Tried using the FindControl() but no luck in finidng this damn textbox having id txtFirstName. Can someone help me with this method? This is what I have been doing but it doesn't work, ...
0
by: BG | last post by:
i am thinking that creating datagrid at design time will save me a lot of time when creating programs. however, i ran into a brick wall. i created a template column at design time. i learned...
3
by: MattB | last post by:
I have a datagrid that has some controls (TextBoxes and DropDownLists) that are created dynamically at runtime. I've got the generation working ok, but now I need to see what was entered or...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
2
by: zambizzi | last post by:
....I can't seem to get my hands on a control I'm loading in an editable datagrid. Here's my datagrid control: <asp:datagrid id="GLRulesGrid" runat="server" autogeneratecolumns="False"...
11
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I am trying to get the text of an item in a GridView, but am doing something wrong. Can someone help me with the correct C# statement I need? Below is my GridView and my attempt to get the control....
5
by: daniel.hedz | last post by:
I am generating a usercontrol dynamically successfully, but when I try to find that usercontrol I get a type mismatch. This is what I am doing: //Loading my usercontrol...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.