Hi, im new to ASP.Net, just playing around with it...

Got a simple question. I am trying to display my Textboxes next to my datagrid, but for some reason, it's always at the bottom of my datagrid. I playing around with this for an introduction to ASP.net. Anyway, i've tried div and it does'nt work for me.

<script runat="server">
void CustomersGridView_SelectedIndexChanged(Object sender, EventArgs e)
{
    SqlConnection thisConnection = new SqlConnection(@"Data Source=prl-sql08-01;Initial Catalog=RemoteDownload;Integrated Security=True");
    using (SqlCommand thisCommand = new SqlCommand(ConfigurationManager.AppSettings["RemoteDownloadConnectionString"]))
    {
        SqlCommand command = new SqlCommand("select * FROM [RemoteDownload].[dbo].[CameronTest]", thisConnection);
        thisConnection.Open();
        SqlDataReader rdr = null;
        rdr = command.ExecuteReader();
        int i = 0;

        while (rdr.Read())
        {
            string a = (string)rdr["Terminal"];
            TextBox Step = new TextBox();
            Step.ID = "Step " + i.ToString();
            Step.TextMode = TextBoxMode.MultiLine;
            Step.Text = a;
            Panel1.Controls.Add(Step);
            i++;
        }
    }
}
</script>


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
        onselectedindexchanged="CustomersGridView_SelectedIndexChanged"
        GridLines="Vertical" AllowSorting="True">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
        </Columns>
        <EditRowStyle BackColor="#7C6F57" />
        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#E3EAEB" />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F8FAFA" />
        <SortedAscendingHeaderStyle BackColor="#246B61" />
        <SortedDescendingCellStyle BackColor="#D4DFE1" />
        <SortedDescendingHeaderStyle BackColor="#15524A" />
    </asp:GridView>

    <asp:Panel ID="Panel1" runat="server"></asp:Panel>

    <br/>

    <asp:label id="MessageLabel"
        forecolor="Red"
        runat="server"/>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:RemoteDownloadConnectionString %>" 
        SelectCommand="USE RemoteDownload SELECT Name FROM sys.Tables">
    </asp:SqlDataSource>
    </form>
</body>
</html>

So, when you run the page, take a look at the source view so you can see what is actually happening. NOt sure if you are already aware, but the ASP.NET controls are processed by the ASP.NET engine and pure HTML is sent back to the browser.

You will notice that you are inserting a textBox control into a panel control. When you look at the source view, you should notice that the panel control was converted into a <div> element and the textbox control was converted into an <input /> element.

How these controls are placed on the screen depends on your styling and the behavior of the controls. For example, div elements are block level elements so an input element will be placed on the next line.

You have to become more familiar with HTML and CSS so you can place the elements appropriately on the screen.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.