Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > FINDCONTROL PROBLEM

Reply
Thread Tools

FINDCONTROL PROBLEM

 
 
Savas Ates
Guest
Posts: n/a
 
      07-21-2006
It is in my <EditItemTemplate> Tag..

<aspropDownList Runat=server ID="CIdeefixeSatis" SelectedIndex='<%#
SelectMyIndex(DataBinder.Eval(Container, "DataItem.ideefixesatis")) %>'

>



<asp:ListItem Value="True">Stokta Var</asp:ListItem>


<asp:ListItem Value="False">Stokta Yok</asp:ListItem>


</aspropDownList>

In my codebehind

Public Function SelectMyIndex(ByVal indexno As Boolean)

ideefixesatisc = CType(Datagrid1.FindControl("CIdeefixeSatis"),
DropDownList)
Response.Write(ideefixesatisc)


End Function
There is no problem with that code..
However When i try to reach
ideefixesatisc. (properties of ideefixesatisc object for example
ideefixesatisc.DataTextField = "OK" )

It returns
Object reference not set to an instance of an object.
ideefixesatisc.DataTextField = "OK"

What can be the problem. . Any idea will be appreciated..




 
Reply With Quote
 
 
 
 
addup
Guest
Posts: n/a
 
      07-21-2006

Savas Ates wrote:
> It is in my <EditItemTemplate> Tag..
>
> <aspropDownList Runat=server ID="CIdeefixeSatis" SelectedIndex='<%#
> SelectMyIndex(DataBinder.Eval(Container, "DataItem.ideefixesatis")) %>'
>
> >

>
>
> <asp:ListItem Value="True">Stokta Var</asp:ListItem>
>
>
> <asp:ListItem Value="False">Stokta Yok</asp:ListItem>
>
>
> </aspropDownList>
>
> In my codebehind
>
> Public Function SelectMyIndex(ByVal indexno As Boolean)
>
> ideefixesatisc = CType(Datagrid1.FindControl("CIdeefixeSatis"),
> DropDownList)
> Response.Write(ideefixesatisc)
>
>
> End Function
> There is no problem with that code..
> However When i try to reach
> ideefixesatisc. (properties of ideefixesatisc object for example
> ideefixesatisc.DataTextField = "OK" )
>
> It returns
> Object reference not set to an instance of an object.
> ideefixesatisc.DataTextField = "OK"
>
> What can be the problem. . Any idea will be appreciated..



Try this:
Datagrid1.Items(Datagrid1.EditItemIndex).FindContr ol("...
in place of Datagrid1.FindControl...

Hope this helps
-- a --

 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      07-21-2006
How does the following evaluate out to a Boolean? ideefixesatisc will
become a reference to the DropDownList, not a boolean.


Public Function SelectMyIndex(ByVal indexno As Boolean)
ideefixesatisc = CType(Datagrid1.FindControl("CIdeefixeSatis"),
DropDownList)
Response.Write(ideefixesatisc)
End Function


 
Reply With Quote
 
Savas Ates
Guest
Posts: n/a
 
      07-24-2006
I changed My function with that but it doesnt work again

Public Function SelectMyIndex(ByVal indexno As Boolean)

Try



ideefixesatisc =
CType(DataGrid1.Items(DataGrid1.EditItemIndex).Fin dControl("CIdeefixeSatis"),
DropDownList)

ideefixesatisc.DataTextField = "Stokta Yok"

Catch ex As Exception

Response.Write(ex)

Response.End()

End Try



Error

System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index) at
System.Web.UI.WebControls.DataGridItemCollection.g et_Item(Int32 index) at
DATAGRID.WebForm1.SelectMyIndex(Boolean indexno) in
C:\Inetpub\wwwroot\DOTNETDENEME\DATAGRID\WebForm1. aspx.vb:line 42


 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      07-24-2006
I'll ask again...


How does the following evaluate out to a Boolean? ideefixesatisc will
become a reference to the DropDownList, not a boolean and your function
doesn't set its return value to anything, so it will always return false.

Public Function SelectMyIndex(ByVal indexno As Boolean)
ideefixesatisc = CType(Datagrid1.FindControl("CIdeefixeSatis"),
DropDownList)
Response.Write(ideefixesatisc)
End Function


"Savas Ates" <in da club> wrote in message
news:%23ezu%(E-Mail Removed)...
>I changed My function with that but it doesnt work again
>
> Public Function SelectMyIndex(ByVal indexno As Boolean)
>
> Try
>
>
>
> ideefixesatisc =
> CType(DataGrid1.Items(DataGrid1.EditItemIndex).Fin dControl("CIdeefixeSatis"),
> DropDownList)
>
> ideefixesatisc.DataTextField = "Stokta Yok"
>
> Catch ex As Exception
>
> Response.Write(ex)
>
> Response.End()
>
> End Try
>
>
>
> Error
>
> System.ArgumentOutOfRangeException: Index was out of range. Must be
> non-negative and less than the size of the collection. Parameter name:
> index at System.Collections.ArrayList.get_Item(Int32 index) at
> System.Web.UI.WebControls.DataGridItemCollection.g et_Item(Int32 index) at
> DATAGRID.WebForm1.SelectMyIndex(Boolean indexno) in
> C:\Inetpub\wwwroot\DOTNETDENEME\DATAGRID\WebForm1. aspx.vb:line 42
>
>



 
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
problem with FindControl Terry ASP .Net 2 02-15-2007 10:02 AM
WebControls and sub controls... problem with FindControl... Why? ThunderMusic ASP .Net 2 10-09-2006 04:26 AM
Findcontrol problem Arjen ASP .Net 2 10-18-2005 02:42 PM
ItemCreated FindControl problem c# =?Utf-8?B?dHBhcmtzNjk=?= ASP .Net 2 06-16-2005 05:11 PM
FindControl problem Jaime ASP .Net 0 05-20-2005 06:49 PM



Advertisments