Click here to Skip to main content
15,664,272 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DLL inside gridview item template. When editing a particular row, the corresponding value will be selected in the dropdownlist.

My gridview looks like this:
<asp:GridView  ID="gvCabinDetails" runat="server" EditRowStyle-BackColor="#f9fae7" RowStyle-BorderColor="#c7c7fa" AutoGenerateColumns="False" DataKeyNames="DecNo,CabinNo" AllowPaging="True" PageSize="5">
      <asp:BoundField DataField="CabinNo" HeaderText="CabinNo" ReadOnly="True" />
         <asp:TemplateField HeaderText="DeckName">
             <asp:DropDownList ID="ddlDeckNo" runat="server"  ></asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlDeckNo" InitialValue="0" ErrorMessage="DecNo is Required">*</asp:RequiredFieldValidator>
              <asp:Label ID="lblDeckNo" runat="server" Text='<%# Bind("DecName") %>'></asp:Label>
<asp:CommandField ShowEditButton="True"  />

In the row editing event, I wrote some code like given below:
'Dim ddl As DropDownList = CType(gvCabinDetails.Rows(e.Row.RowIndex).FindControl("ddlDeckNo"), DropDownList)
           If Not ddl Is Nothing Then
               ddl.DataSource = objCabinDetails.SelectDeckNo
               ddl.DataTextField = "DecName"
               ddl.DataValueField = "DecNo"
           End If
Updated 30-Jan-11 20:54pm
Abhinav S 31-Jan-11 2:00am    
Is there an error somewhere or is your code simply not working?
Sandeepost 31-Jan-11 2:05am    
ddl is not binding
Sandeep Mewara 31-Jan-11 4:05am    
Not sure what exactly you are looking for. Looks like incomplete question.
vishv 2-Feb-11 0:37am    
Question is not as much clear as it should be.

1 solution

Where are you getting the "objCabinDetails.SelectDeckNo" from, and what is it's type.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900