Home All Groups Group Topic Archive Search About

DATAGRID DROPDOWN PROBLEM

Author
21 Jul 2006 8:28 AM
Savas Ates
It is in my <EditItemTemplate> Tag..

<asp:DropDownList 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>


</asp:DropDownList>

In my codebehind

Public Function SelectMyIndex(ByVal indexno As Boolean)

            ideefixesatisc = CType(Page.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..

Author
21 Jul 2006 9:35 AM
Cor Ligthert [MVP]
Savas,

This is at leaset the thirth time that you are asking about the same
question, will you keep it to your original question.

In this idea everybody is starting everytime again investigating your
problem.

I tested it, gave you the code, but you did not give any reply on that.

The problem is probabably obvious. But I don't spread my answers over 10
messages so nobody understand anymore (by instance when searching this
newsgroup) what I am answering.


Cor

Show quoteHide quote
"Savas Ates" <in da club> schreef in bericht
news:uqM0b%23JrGHA.3908@TK2MSFTNGP05.phx.gbl...
>
> It is in my <EditItemTemplate> Tag..
>
> <asp:DropDownList 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>
>
>
> </asp:DropDownList>
>
> In my codebehind
>
> Public Function SelectMyIndex(ByVal indexno As Boolean)
>
>            ideefixesatisc = CType(Page.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..
>
>
>
>
>
>
>
>
Author
21 Jul 2006 9:59 AM
Savas Ates
The problem is that It cant find the   control

I changed the Page.findcontrol with  Me.DataGrid1.FindControl

They both give the same error..
ideefixesatisc = CType(Me.DataGrid1.FindControl("CIdeefixeSatis"),
DropDownList)



I have  that hierarchie

<asp:DataGrid id="DataGrid1"
<Columns>
<EditItemTemplate>
<asp:DropDownList Runat=server ID="CIdeefixeSatis"


How can i achieve to get my control  to be finded with .Findcontrol Method.
?


Error Message
System.NullReferenceException: Object reference not set to an instance of an
object. at DATAGRID.WebForm1.SelectMyIndex(Boolean indexno) in
C:\Inetpub\wwwroot\DOTNETDENEME\DATAGRID\WebForm1.aspx.vb:line 40