dropdownlist in datagrid edit mode

  • Thread starter Luis Esteban Valencia
  • Start date
L

Luis Esteban Valencia

I need to put in the edit mode a dropdownlist with the correct value
selected.



On the template I have this

<ItemTemplate>
<asp:Label id=Label4 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.strTipoContrato") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>

<asp:DropDownList id="tipocontratot"
runat="server"></asp:DropDownList>
</EditItemTemplate>

On the codebehind I have this.

Private Sub dgpolizas_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgpolizas.ItemCommand

Select Case e.CommandName

Case "Edit"

dgpolizas.EditItemIndex = e.Item.ItemIndex

cargarpolizas()

Dim tipocontratot As DropDownList

tipocontratot = e.Item.FindControl("tipocontratot")

Dim myadp As New SqlDataAdapter("select * from tbltipocontrato", myconn)

Dim myds As New DataSet

myadp.Fill(myds, "tbltipocontrato")

tipocontratot.DataSource = myds.Tables("tbltipocontrato").DefaultView

tipocontratot.SelectedValue = ???

tipocontratot.DataBind()



Thanks
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top