VS.NET: DropDownList in EditItemTemplate of DataGrid
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdatagridrepeaterdatalist' list.


TBrewi@aol.com
-- Copied from [aspngvs] to [aspngdatagridrepeaterdatalist] by Tony Stark <Click here to reveal e-mail address> --

Is this not possible? I'm trying to bind text and values to a DrowDownList
that's in an EditItemTemplate of a DataGrid. There's no compile errors or
warning. But at run-time I get "Object reference not set to an instance of
an object" on the line where I set the DrowDownList DataSource.

If I move the DrowDownList out of the EditItemTemplate to some other part of
the page, the data binds successfully.

There's something strange about this DrowDownList... When I first added the
DrowDownList to the EditItemTemplate, VS did not automatically add a
declaration for the DrowDownList in the code-behind like it always does with
other controls. Then when I manually declared the DrowDownList in the
code-behind, the page's design view started showing "Error creating control",
saying that there is already a component with this name.

I always blame myself first when something goes wrong, but this is looking
more and more like a bug in VS. Can anyone tell me how I can get this to
work? Thanks!

-- Tim :)

Timothy M. Brewi

Reply to this message...
 
    
TBrewi@aol.com
Jesudas,

Thank you very much! Your article was VERY helpful. The dropdownlist in my
datagrid is working perfectly now.

I may have misunderstood, but the article SEEMS to have two errors:

(1) The attribute for data value field should be...

<asp:DropDownList id="cboState" DataSource="<%# BindState() %>"
DataTextField="Statename" DataValueField="Statename" runat="server" />

instead of...

<asp:DropDownList id="cboState" DataSource="<%# BindState() %>" DataTextFiel
d="Statename" DataTextValue="Statename" runat="server" />

(2) The BindState function should be declared...

Protected Function BindState()

instead of...

Private Function BindState()

If it's declared Private, the you get a compilation error on the HTML page
saying that the function is "not accessible in this context because it is
private".

Thank you again for your helpful article!

-- Tim :)

Timothy M. Brewi

<clip>

[Original message clipped]

Reply to this message...
 
    
Das
Ofcourse, this is possible. Read my article
DataGrid and DropDownLists
http://aspalliance.com/das/dgcombo.aspx" target="_blank">http://aspalliance.com/das/dgcombo.aspx

which talks about the same issue that you have described.

:-)
Jesudas Chinnathampi (Das)

Co-Author - Beginning ASP.NET Databases using VB.NET
http://www.amazon.com/exec/obidos/ASIN/1861006195

Read my articles on ASP .NET at
http://aspalliance.com/das

----- Original Message -----
From: <Click here to reveal e-mail address>
To: "aspngDataGridRepeaterDatalist"
<Click here to reveal e-mail address>
Sent: Sunday, July 21, 2002 2:47 PM
Subject: [aspngdatagridrepeaterdatalist] VS.NET: DropDownList in
EditItemTemplate of DataGrid

> -- Copied from [aspngvs] to [aspngdatagridrepeaterdatalist] by Tony Stark
<Click here to reveal e-mail address> --
[Original message clipped]

Reply to this message...
 
    
Das
Thanks for the suggestions. Let me look into this. I am not sure how did
I missed these stuffs.

Now, I have updated my article with another aspect with:
"Presetting items in a dropdownlist which is in the edit mode of the
datagrid"
http://aspalliance.com/das/dgcombo.aspx" target="_blank">http://aspalliance.com/das/dgcombo.aspx

:-)
Jesudas Chinnathampi (Das)

Co-Author - Beginning ASP.NET Databases using VB.NET
http://www.amazon.com/exec/obidos/ASIN/1861006195

Read my articles on ASP .NET at
http://aspalliance.com/das

----- Original Message -----
From: <Click here to reveal e-mail address>
To: "aspngDataGridRepeaterDatalist"
<Click here to reveal e-mail address>
Sent: Tuesday, July 23, 2002 3:32 AM
Subject: [aspngdatagridrepeaterdatalist] VS.NET: DropDownList in
EditItemTemplate of DataGrid

[Original message clipped]

Reply to this message...
 
 
System.Web.UI.WebControls.DataGrid
System.Web.UI.WebControls.DropDownList
System.Windows.Forms.DataGrid




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com