DropDowns in GridView

M

MRW

I have a GridView which displays simple labels in ItemTemplate, and
when it goes to EditTemplate, one field is a dropdown list and the
other is a text box.

On gvTT_RowUpdating(..), I'm able to access the text box without any
issue, using:

Dim newDate As TextBox = gvTT.Rows(gvTT.EditIndex).FindControl("Date")

However, for the dropdown, when I use:

Dim ddlCategories As DropDownList =
gvTT.Rows(e.RowIndex).FindControl("ddlCategories")

I can access all the properties of the dropdown (being it's finding
it), however, I cannot access the selected value!

Response.Write(ddlCategories.SelectedIndex)

Does anybody know why I cannot access the dropdown list, yet I can
access the text boxes???

Thanks for ANY help!
 
N

nahid

I have a GridView which displays simple labels in ItemTemplate, and
when it goes to EditTemplate, one field is a dropdown list and the
other is a text box.

On gvTT_RowUpdating(..), I'm able to access the text box without any
issue, using:

Dim newDate As TextBox = gvTT.Rows(gvTT.EditIndex).FindControl("Date")

However, for the dropdown, when I use:

Dim ddlCategories As DropDownList =
gvTT.Rows(e.RowIndex).FindControl("ddlCategories")

I can access all the properties of the dropdown (being it's finding
it), however, I cannot access the selected value!

Response.Write(ddlCategories.SelectedIndex)

Does anybody know why I cannot access the dropdown list, yet I can
access the text boxes???

Thanks for ANY help!

hi,
did you try this
gvTT.Rows(e.RowIndex).FindControl("ddlCategories").SelectedItem.Value
hope it will work

thanks
nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
 

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

Top