ItemIndex of add events



I created a datagrid with a footer that used to add a row. This worked
for my other datagrids but this datagrid had two columns with
dropdownlists in the footer. The first dropdownlist is supposed to
trigger a change to the contents of the second dropdownlist.

This works fine with an edit because I have EditItemIndex. But with an
add I can't figure out how to get the right index. Here's what the
logic looks like, I have one subroutine to handle the various
dropdownlist changes:

Protected Sub ddlTest_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
Dim ddl As DropDownList = CType(sender, DropDownList)
Dim aSqlParams As Array =
Array.CreateInstance(GetType(SqlParameter), 1)
Dim sName As String = ddl.ID

Select Case sName
Case "ddlOneAdd"
Case "ddlOneEdit"
aSqlParams.SetValue(New SqlParameter("@catid",
ddl.SelectedItem.Value), 0)
ddl =
BindDropDownList(ddl, "sp_name", "value", "text",
End Select
End Sub

As I said, the Edit routine works because I can use
grdTest.EditItemIndex to do my FindControl to get to the second

How can I get the correct index when the rows are in the footer and
there isn't any corresponding index value to retrieve?


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