HighTechTalks DotNet Forums  

FINDCONTROL PROBLEM

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss FINDCONTROL PROBLEM in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Savas Ates
 
Posts: n/a

Default FINDCONTROL PROBLEM - 07-21-2006 , 09:54 AM






It is in my <EditItemTemplate> Tag..

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

Quote:

<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
  #2  
Old   
addup
 
Posts: n/a

Default Re: FINDCONTROL PROBLEM - 07-21-2006 , 01:47 PM







Savas Ates wrote:
Quote:
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
  #3  
Old   
Scott M.
 
Posts: n/a

Default Re: FINDCONTROL PROBLEM - 07-21-2006 , 03:47 PM



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
  #4  
Old   
Savas Ates
 
Posts: n/a

Default Re: FINDCONTROL PROBLEM - 07-24-2006 , 04:27 AM



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
  #5  
Old   
Scott M.
 
Posts: n/a

Default Re: FINDCONTROL PROBLEM - 07-24-2006 , 04:26 PM



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

Quote:
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 Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.