Ask a Question related to ASP.NET General, Design and Development.
-
pete #1
DropDownList control in DataGrid
Hello all,
I'l displaying a dropdownlist inside a datagrid. The problem comes when I
try to get the values the user chose on postback.
If I rebind the datagrid, the values of the dropdownlist are all set back to
their original values. If I do not rebind the datagrid, I don't seem to have
access to the dropdownlist at all.
Code fragment:
For Each dgItem In Me.dgPlayerList.Items
strID = dgItem.Cells(0).Text
Dim ddlTeam As New DropDownList()
ddlTeam = dgItem.FindControl("ddlTeams")
strTeam = ddlTeam.SelectedItem.Value
I get the "Object reference not set to an instance of an object" on the last
line there when I do not rebind. I was under the impression that datagrids
had to be rebound on postback to access their contents, but I'm obviously
missing something. Hopefully something simple.
Thanks for any suggestions,
pete
pete Guest
-
Dropdownlist Control in DataGrid Not Updating After Databind
I seem to be having trouble getting my Datagrid label to Update correctly after clicking on update from a dropdownlist. I implemented the scheme... -
Respond to DropDownList control Event in DataGrid
I am adding a DropDownList control to my DataGrid footer template. I load my DropDownList using a function that returns an arrayList. I can see... -
dropdownlist control
I have a form which displays a number of text boxes that are all data bound to a dataset. I want to change one of these text boxes to be a drop... -
How to Bind a DropDownList control to a DataGrid in Template Column?
I'm having a tough time with this, and I can't find any resources that address it. I have a DataGrid comprised of Template Columns, in which I have... -
Error Binding DropDownList on EditItem Command of DataGrid Control
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a... -
Naveen K Kohli #2
Re: DropDownList control in DataGrid
You don't have to rebind the grid on postback.
Where in the code are you trying to get the selected values? You should be
doing it after Page_Load has completed. Preferably inthe event handler of
the control that triggered the post back.
--
Naveen K Kohli
[url]http://www.netomatix.com[/url]
"pete" <peter@invalid.com> wrote in message
news:uQsZ5lAQDHA.2052@TK2MSFTNGP11.phx.gbl...to> Hello all,
>
> I'l displaying a dropdownlist inside a datagrid. The problem comes when I
> try to get the values the user chose on postback.
>
> If I rebind the datagrid, the values of the dropdownlist are all set backhave> their original values. If I do not rebind the datagrid, I don't seem tolast> access to the dropdownlist at all.
>
> Code fragment:
>
> For Each dgItem In Me.dgPlayerList.Items
> strID = dgItem.Cells(0).Text
> Dim ddlTeam As New DropDownList()
> ddlTeam = dgItem.FindControl("ddlTeams")
> strTeam = ddlTeam.SelectedItem.Value
>
> I get the "Object reference not set to an instance of an object" on the> line there when I do not rebind. I was under the impression that datagrids
> had to be rebound on postback to access their contents, but I'm obviously
> missing something. Hopefully something simple.
>
> Thanks for any suggestions,
>
> pete
>
>
>
Naveen K Kohli Guest



Reply With Quote

