Hi Mark,
I can not reproduce the problem. Here is my code.
After the page is displayed in IE,all the DropDownList in the datagrid
displayed the 10th item.
Public WithEvents dl As DropDownList
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.PreRender
Response.Write(dl.SelectedIndex)
End Sub
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
Dim o As Object
o = CType(e.Item.FindControl("DropDownList1"), DropDownList)
If Not o Is Nothing Then
dl = o
dl.SelectedIndex = 10
End If
End Sub
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
Response.Write(dl.SelectedIndex)
End Sub
Private Sub dl_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dl.PreRender
Response.Write(dl.SelectedIndex)
End Sub
Can you post your code for me to reproduce the problem?
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure!
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Mark Waser" <mw****@mwaser.com>
References: <OE**************@tk2msftngp13.phx.gbl>
<sQ**************@cpmsftngxa06.phx.gbl>Subject: Re: Odd BUG with DropDownList in DataGrid
Date: Mon, 10 Nov 2003 09:13:06 -0500
Lines: 124
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <OZ**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 12.154.72.87
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:155524
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
But the value of datagrid's selectedindex is different between the
Page's PreRender and the datagrid's PreRender event.
I'm sorry, I wrote the wrong thing. I should have said that the
DROPDOWNLIST's selectedindex is different between the Page's PreRender and
the List's PreRender. The problem here being that the dropdownlist is
supposed to be set to a specific value (according to the data for a
specificitem) during databinding (and it is) but that value is subsequently lost
before the user sees it.
Thanks.
Mark
"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:sQ**************@cpmsftngxa06.phx.gbl... Hi Mark,
Based on my understanding you are developing an ASP.NET application, and
on the webform you add a datagrid and add the dropdownlist as the datagrid's
template item.
But the value of datagrid's selectedindex is different between the
Page's PreRender and the datagrid's PreRender event.
If so,
Here is my test code that I can not reproduce the problem.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
SqlDataAdapter1.Fill(DataSet11)
DataGrid1.DataBind()
Me.DataGrid1.SelectedIndex = 10
End Sub
Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.PreRender
Response.Write(Me.DataGrid1.SelectedIndex.ToString ()) 'the value
is 10
End Sub
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
Response.Write(Me.DataGrid1.SelectedIndex.ToString ()) 'the value
is 10
End Sub
And I am strange why you will mention the DropDownList here.
If I misunderstanding your meaning, please post here.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights. -------------------- >From: "Mark Waser" <mw****@mwaser.com>
>Subject: Odd BUG with DropDownList in DataGrid
>Date: Fri, 7 Nov 2003 11:06:48 -0500
>Lines: 38
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <OE**************@tk2msftngp13.phx.gbl>
>Newsgroups: microsoft.public.dotnet.languages.vb
>NNTP-Posting-Host: 12.154.72.87
>Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFT NGP08.phx.gbl!tk2msftngp13