Hi, I have a DetailsView on my page that connects to a SQL server D/B and shows its data.However, It is not visible on my page when I launch my browser. Any ideas or past experience with this? Thanks for reading.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="page.aspx.cs" Inherits="Restricted_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0047)http://localhost:51704/DeaDtsAsp/LoginPage.aspx -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="MShtml 6.00.6000.16587" name="GENERATOR"/><link rel="stylesheet" type="text/css" href="demo.CSS" /></head>


<body runat="server">

<h1 runat="server" visible="true">You are logged in</h1>
    <h1 runat="server" visible="true">
        Sponsor with the following details:</h1>
    <p>
        &nbsp;</p>
   <p runat="server" visible="false">
        &nbsp;<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:demoConnectionString %>" 
            SelectCommand="SELECT [username], [role], [email], [tel], [fax], [organisation] FROM [users] WHERE ([username] = @username)"
            OnSelecting="SqlDataSource1_Selecting" ProviderName="<%$ ConnectionStrings:demoConnectionString.ProviderName %>">
            <SelectParameters>
                <asp:ProfileParameter Name="username" PropertyName="username" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
            Height="0px" Width="0px" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="0px" CellPadding="4" 
            ForeColor="Black" OnPageIndexChanging="DetailsView1_PageIndexChanging" EmptyDataText="N/A">
            <Fields>
                <asp:BoundField DataField="username" HeaderText="username" SortExpression="username" />
                <asp:BoundField DataField="role" HeaderText="role" SortExpression="role" />
                <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
                <asp:BoundField DataField="tel" HeaderText="tel" SortExpression="tel" />
                <asp:BoundField DataField="fax" HeaderText="fax" SortExpression="fax" />
                <asp:BoundField DataField="organisation" HeaderText="organisation" SortExpression="organisation" />
            </Fields>
            <FooterStyle BackColor="#CCCC99" />
            <RowStyle BackColor="#F7F7DE" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:DetailsView>
        &nbsp;
    </p>
</body></html>

interesting I added this code in the C# code behind file as I read that it would prevent the error message described below:

Code:

//public override void VerifyRenderingInServerForm(Control control)
    //{

    //}

the error msg was

Exception Details: System.Web.HttpException: Control 'DetailsView1' of type 'DetailsView' must be placed inside a form tag with runat=server

Thought that might help you all help me lol. Thanks

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Forgot, here is the stack trace:

HttpException (0x80004005): Control 'DetailsView1' of type 'DetailsView' must be placed inside a form tag with runat=server.]
   System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +2049759
   System.Web.UI.WebControls.DetailsView.Render(HtmlTextWriter writer, Boolean renderPanel) +37
   System.Web.UI.WebControls.DetailsView.Render(HtmlTextWriter writer) +30
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
   System.Web.UI.Page.Render(HtmlTextWriter writer) +26
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint

have realised that putting the details view inside <form runat="server"> tag has same effect as
//public override void VerifyRenderingInServerForm(Control control)
//{

//}

the odd thing is when I try to run this code on an XP machine (as opposed to vista home basic) it works fine........odd. Any ideas?

Careful, XP professional edition comes basically server ready, while vista home basic does not. And they actually prevent you from using vista home basic as a server.

how generous! lol thanks mate for your replies. Do you have any suggestions? other than an XP installation lol

You don't need IIS if you have Visual Studio 2005 Express Edition (any edition 2005+) It includes a web server. When you run the app from VS (F5 to debug, or Ctrl+F5 to run without debugger) it starts up automatically on http://localhost:<some random port number> (you get an icon in your sys tray too showing it's running)

Comments
very polite & helpful

interestingly, after downgrading to xp and using gridview I am able to display my d/b! Yippee! I wonder why that would not work in vista?! Trying to get update working now and delete

after hitting the auto generated update button:
You have specified that your update command compares all values on SqlDataSource 'SqlDataSource1', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges.

any ideas?
thanks

its ok fixed it lol turned off optimistic concurrency then it worked. does anybody know why that might be ?

ok so I know gridview works with the edit/delete buttons that are built in with gridview, but how would I go about using my own (separate buttons) ?

Those buttons use commands, then based on those commands they use the datasources to update.

You would have to insert your own button with a new command argument. Then create a sub that it references where then reference the command arguments. Based upon which argument is passed, will tell you which performance is done.

so a user will select a row using the built in select (button on grid) then press edit, where i can redirect them to a new page to edit details and so forth. after edit is done, a save button throws back edits to d/b and returns user to original menu! lol is that do-able?

yes it is doable. You will need to do an on Itemcreated event and search through for those buttons. Then reset the onclick function to trigger a new sub, which then will redirect based upon the command it receives. Also set a fake attribute to it to keep the current row id.

ok thanks for the help (again!) have got the data to fill in some text boxes now using SESSION. very handy tool! what I now need is changes that are made on this page to be sent back to d/b (update). I am going to battle this one now! thanks again!

This question has already been answered. Start a new discussion instead.