Get value from datagrid DDL cell OnSelectedIndexChange

S

steve roszko

I have a dropdownlist in a column of my datagrid. When
the user
changes the value in the ddl, I want to fire off
OnSelectedIndexChange
event and do an update based on the id held in a hidden
column of the
grid. But I cannot seem to get to that cell info from my
OnSelectedIndexChange procedure.

Here is some of the code:

[DATA GRID SETUP]

<Columns>
<asp:BoundColumn Visible=false ReadOnly=True
DataField="projDetailID"
HeaderText="ID" />
<asp:TemplateColumn headertext="% Complete"
SortExpression="PercentComplete" >
<ItemTemplate>
<asp:DropDownList id="ddlPercentComplete" runat="server"
AutoPostBack=True
OnPreRender="SetPercentIndex"
OnSelectedIndexChanged="RecordPercentDone"</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</columns>


Public Sub RecordPercentDone(ByVal sender As Object, ByVal
e As
System.EventArgs)
'this is where I am trying to get the ID value of the row
'that the ddl index was changed
'once I get the ID, I can then write the real code for
the update

Dim ed As DropDownList = CType(sender, DropDownList)
Dim mylbl As Label = CType(ed.Parent.Parent.FindControl
("ID"),
Label)

Me.lblOutput.Text += mylbl.Text & "<BR>"

Dim dg As DataGrid = CType(ed.Parent.Parent, DataGrid)
Me.lblOutput.Text += mycell.Text & "<BR>"
Me.lblOutput.Text += dg.Items.Item(0).Cells
(0).Text.ToString() &
"<BR>"
Me.lblOutput.Text += ed.Parent.GetType.ToString & "<BR>"
End Sub

Thanks!!

Steve
 
S

steve

I figured out the solution.

Public Sub RecordPercentDone(ByVal sender As Object, ByVal
e As System.EventArgs)
Dim ed As DropDownList = CType(sender, DropDownList)
Dim myDatGridItem As DataGridItem = CType
(ed.Parent.Parent, DataGridItem)

Dim projDetailID As String = myDatGridItem.Cells(0).Text
Dim PercentComplete As String = ed.SelectedItem.Text
Do Update......
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top