TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sri ranjani
NA
81
4.2k
How to populate dropdown value in edit mode for detailview
Jul 18 2018 7:07 AM
Hi all,
I've a Field site
<asp:TemplateField HeaderText="Site" SortExpression="SITE">
<EditItemTemplate>
<asp:DropDownList ID= "TxtsiteEdit" runat="server" Text='<%# Bind("SITE") %>' AppendDataBoundItems="true" TabIndex="6">
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID= "TxtsiteInsert" runat="server" AutoPostBack="True" OnSelectedIndexChanged="sitedropdown_SelectedIndexChanged" TabIndex="6">
<asp:ListItem Text="Select Site"></asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="TxtSite" runat="server" Text='<%# Bind("SITE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
I'm populating this site value using this method from another field selected index changed:
Private Sub Fillsite()
Dim IdtxtSiteInsert As DropDownList = CType(DetailsView3.Rows(0).FindControl("TxtsiteInsert"), DropDownList)
Dim strConn As String = WebConfigurationManager.ConnectionStrings("BMGINC_DYNAX09_ProdConnectionString").ConnectionString
Dim con As New SqlConnection(strConn)
Dim cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select SiteId, Name from InventSite"
Dim objDs As New DataSet()
Dim dAdapter As New SqlDataAdapter()
dAdapter.SelectCommand = cmd
con.Open()
dAdapter.Fill(objDs)
con.Close()
If objDs.Tables(0).Rows.Count > 0 Then
IdtxtSiteInsert.DataSource = objDs.Tables(0)
IdtxtSiteInsert.DataTextField = "SiteId"
IdtxtSiteInsert.DataValueField = "SiteId"
IdtxtSiteInsert.DataBind()
IdtxtSiteInsert.Items.Insert(0, "-Select-")
Else
LblError.Text = "No Site found"
End If
End Sub
i need to populate the field value same like insert when i click edit in detailview
Thanks in advance
Reply
Answers (
1
)
console error when click the insert button
What is main use of ChildActionOnly in mvc?