Hi Potato:
I have some articles with C# source that might help. They talk about
the basics of using FindControl and using DropDownLists in a grid.
In Search Of ASP.NET controls
http://odetocode.com/116.aspx
Embedding DropDownList Controls In A Grid
http://odetocode.com/Articles/231.aspx
HTH,
--
Scott
http://www.OdeToCode.com
On Tue, 07 Sep 2004 14:37:16 GMT, mystical_potato
<> wrote:
>From VS.NET 03 AND VB.NET
>
>I added a dropdown list to a data grid control in response to the
>EditCommand event to force users to pick values from a list and not
>type them in. I used the following code:
>
> 'Hide the existing txt box
> Dim txt As TextBox
> txt = CType(e.Item.Cells(0).Controls(0), TextBox)
> txt.Visible = False
>
> 'display a ddl instead
> Dim ds As New DataSet
> ds = dbCalls.GetData
> Dim ddl As New DropDownList
> ddl.ID = "myID"
> ddl.DataSource = ds
> ddl.DataTextField = "myTxt"
> ddl.DataValueField = "myID"
> ddl.DataBind()
> ddl.Attributes.Add("class", "myCSS")
> e.Item.Cells(0).Controls.Add(ddl)
>
>This works great (everything displays as intended in the UI).
>However, when I code the UpdateCommand I cannot find the DropDownList
>control I created above. When I debug and add a watch for
>e.Item.Cells(0) it only shows a single control
>(e.Item.Cells(0).controls(0) which is the text box). How can I
>reference the DropDownList control? I am using the following code:
>
>Dim ddlMaintCatID As DropDownList
>ddlMaintCatID = CType(e.Item.Cells(0).Controls(X), DropDownList)
>
>For X i tried the following vales (0 and 1). For 0 I get and invalid
>cast error becuase controls(0) is a text box and for 1 I get an index
>out of range error.
>
>What am I missing???
>
>thanks in advance for your time and assistance.
>Scott