I have a details view that is supposed to display one record from a master gridview on another page. I had this working but "broke" it.I am binding the detailsview programmatically to datareader. There are no errors but the Detailsview is not visible.If I eamine the data from the data reader it is correct.
<%@ Page Title="" Language="
vb"
AutoEventWireup="true" MasterPageFile="~/boost.master"%>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
lblIssues.Text = "Select up to 5 issues"
lblIssues.ForeColor = Drawing.Color.Black
PopulateDetailsView()
End If
End Sub
Protected Sub PopulateDetailsView()
Dim Conn As New SqlConnection(SqlDataSource1.ConnectionString)
Dim objDR As SqlDataReader
Dim Cmd1 As New SqlCommand("procGetAdByIdSelect", Conn)
Dim AdId As Integer
Dim Email, FName, Headline, Adtext, URL, Searchterm, ProdSvce As String
Dim Issue1, Issue2, Issue3, Issue4, Issue5 As String
Cmd1.CommandType = Data.CommandType.StoredProcedure
Cmd1.Parameters.AddWithValue("@adid", Session("adid"))
Conn.Open()
objDR = Cmd1.ExecuteReader(System.Data.CommandBehavior.Clo seConnection)
If objDR.HasRows Then
While objDR.Read
AdId = CType(objDR("adid"), Integer)
Email = CType(objDR("Email"), String)
FName = CType(objDR("FName"), String)
Headline = CType(objDR("Headline"), String)
Adtext = CType(objDR("Adtext"), String)
URL = CType(objDR("URL"), String)
Searchterm = CType(objDR("Searchterm"), String)
ProdSvce = CType(objDR("ProdSvce"), String)
Issue1 = CType(objDR("Issue1"), String)
Issue2 = CType(objDR("Issue2"), String)
Issue3 = CType(objDR("Issue3"), String)
Issue4 = CType(objDR("Issue4"), String)
Issue5 = CType(objDR("Issue5"), String)
End While
End If
DetailsView1.DataSource = objDR
DetailsView1.DataBind()
DetailsView1.Visible = "True"
objDR.Close()
Conn.Close()
End Sub
Protected Sub SendMessage()
Dim whosent As String
whosent = "
[email protected]"
Dim Conn As New SqlConnection(dsEmail.ConnectionString)
Dim recipient As String
Dim mailServerName As String = "Mail.boostctr.com"
Dim mailClient As SmtpClient = New SmtpClient
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("xxxxxxcom", "xxxxxx")
Dim message As MailMessage
Dim MediaType As String = "text/html"
mailClient.Host = "mail.boostctr.com"
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo
recipient = "
tbd"
message = New System.Net.Mail.MailMessage(whosent, recipient)
message.Subject = "
tbd"
End Sub
Protected Sub btnSendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SendMessage()
End Sub
Protected Sub CheckBoxListIssues_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ItemsSelectedCount As Integer
ItemsSelectedCount = 0
For Each LItems As ListItem In CheckBoxListIssues.Items
If LItems.Selected = True Then
ItemsSelectedCount = ItemsSelectedCount + 1
End If
Next
Session("TooManyIssues") = False
If ItemsSelectedCount > 5 Then Session("TooManyIssues") = "True"
If Session("TooManyIssues") = "True" Then
lblIssues.Text = "Only 5 Issues Allowed"
lblIssues.ForeColor = Drawing.Color.Red
Else
lblIssues.Text = "Select up to 5 issues"
lblIssues.ForeColor = Drawing.Color.Black
End If
End Sub
Protected Sub btnApplyIssues_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Session("TooManyIssues") = "True" Then
lblIssues.Text = "Only 5 Issues Allowed"
lblIssues.ForeColor = Drawing.Color.Red
Exit Sub
Else
lblIssues.Text = "Select up to 5 issues"
lblIssues.ForeColor = Drawing.Color.Black
End If
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:steve48ConnectionString %>">
</asp:SqlDataSource>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" CssClass="detailsview">
<Fields>
<asp:BoundField DataField="AdID" HeaderText="AdID" InsertVisible="False"
ReadOnly="True" SortExpression="AdID" />
<asp:BoundField DataField="EMail" HeaderText="EMail" SortExpression="EMail" />
<asp:BoundField DataField="FName" HeaderText="FName" SortExpression="FName" />
<asp:BoundField DataField="Headline" HeaderText="Headline"
SortExpression="Headline" />
<asp:BoundField DataField="Adtext" HeaderText="Adtext"
SortExpression="Adtext" />
<asp:BoundField DataField="URL" HeaderText="URL" SortExpression="URL" />
<asp:BoundField DataField="Searchterm" HeaderText="Searchterm"
SortExpression="Searchterm" />
<asp:BoundField DataField="ProdSvce" HeaderText="ProdSvce"
SortExpression="ProdSvce" />
<asp:BoundField DataField="Issue1" HeaderText="Issue1"
SortExpression="Issue1" />
<asp:BoundField DataField="Issue2" HeaderText="Issue2"
SortExpression="Issue2" />
<asp:BoundField DataField="Issue3" HeaderText="Issue3"
SortExpression="Issue3" />
<asp:BoundField DataField="Issue4" HeaderText="Issue4"
SortExpression="Issue4" />
<asp:BoundField DataField="Issue5" HeaderText="Issue5"
SortExpression="Issue5" />
<asp:CheckBoxField DataField="Active" HeaderText="Active"
SortExpression="Active" />
<asp:BoundField DataField="ReviewerID" HeaderText="ReviewerID"
SortExpression="ReviewerID" />
</Fields>
</asp:DetailsView>
<div style="text-align:center;">
<asp:Button ID="btnSendEmail" runat="server" Text="Send Email" onclick="btnSendEmail_Click"
class="button"/>
<br />
</div>
<div >
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div style="text-align:center;">
<asp:Label ID="lblIssues" runat="server" Text="" ForeColor="#CC3300"></asp:Label>
</div>
<asp:CheckBoxList class="tablecenter" ID="CheckBoxListIssues" runat="server" AutoPostBack="True"
TextAlign="Right" style="position: relative" OnSelectedIndexChanged="CheckBoxListIssues_Selecte dIndexChanged">
<asp:ListItem>Stronger Call To Action</asp:ListItem>
<asp:ListItem>Punctuation</asp:ListItem>
<asp:ListItem>Awkward Grammar</asp:ListItem>
<asp:ListItem>Use Caps In The Display URL</asp:ListItem>
<asp:ListItem>No Product Benefit</asp:ListItem>
<asp:ListItem>No Product Features</asp:ListItem>
<asp:ListItem>Stronger Call To Action</asp:ListItem>
<asp:ListItem>Differentiate From Competitors</asp:ListItem>
<asp:ListItem>Repeating Words</asp:ListItem>
<asp:ListItem>Keywords Not in Title</asp:ListItem>
<asp:ListItem>Lack of Brand Recognition</asp:ListItem>
</asp:CheckBoxList>
<div style="text-align:center;">
<asp:Button ID="btnApplyIssues" runat="server" Text="Apply Issues" onclick="btnApplyIssues_Click"
class="button"/>
<br />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<asp:SqlDataSource ID="dsEmail" runat="server">
</asp:SqlDataSource>
</asp:Content>