Get value from datagrid DDL cell OnSelectedIndexChange

  • Thread starter Thread starter steve roszko
  • Start date Start date
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
 
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
 
Back
Top