Link to home
Start Free TrialLog in
Avatar of programmher
programmher

asked on

C# Question about query results

Here is the code.  This question is specifically about the SQL portion of the code:
<%@ Page Title="" Language="C#" MasterPageFile="~main.master" %>
 <script runat="server">

protected void btnAdd_Click(object sender, EventArgs e)
{
    sqlBooks.Insert();
    txtNewBook.Text = String.Empty;
    gvBooks.DataBind();
}
 </script>
 <asp:Content ID="Content2" ContentPlaceHolderID="cphMain" Runat="Server">
 <div id="awindow" >
<asp:Panel ID="Panel1" runat="server" CssClass="mainContent">
<div style="width: 100%; float: left">    
    <asp:Image ID="Image1" runat="server" ImageUrl=" "  Width="100%"/>
    <asp:TextBox runat="server"  style="margin-left:5px; float:left;" ID="txtNewTitle" />
    <asp:ImageButton runat="server" ID="btnAddTitle" Height="17px" ToolTip="Add New Book"      ImageUrl="~insert.png" OnClick="btnAd_Click"/>
</div>
<asp:SqlDataSource runat="server" ID="sqlBookLibs" ConnectionString="<%$   ConnectionStrings:dbbooks %>" ProviderName="<%$ ConnectionStrings:AllBooks.ProviderName %>" 
    SelectCommand="SELECT * FROM BookTitles ORDER BY Titles" 
    InsertCommand="BookTitles_GetOrCreate" InsertCommandType="StoredProcedure">
    <InsertParameters>
        <asp:ControlParameter ControlID="txtNewTitle" Name="titlename" />
    </InsertParameters>
</asp:SqlDataSource>

    <asp:GridView runat="server" ID="gvBooks" DataSourceID="sqlBookTitles" DataKeyNames="BookTitles" AutoGenerateColumns="false">
        <Columns>
            <asp:HyperLinkField HeaderText="Book Name"  DataNavigateUrlFormatString="~/BookTitles/Books.aspx?id={0}" DataNavigateUrlFields="PartnerID" DataTextField="BookName" />
        </Columns>
        <Columns>
             <asp:HyperLinkField HeaderText="Find Book Titles"  DataNavigateUrlFields="" DataTextField="" />

        </Columns>
    </asp:GridView>
</asp:Panel>
</div>
</asp:Content>

Open in new window


My question is- shouldn't I be able to use the result of the above SQL query in other text boxes, drop down boxes, and text areas I include on this page without re-running the query?  

If so, wouldn't I do that by just referencing the ID in the textbox or text area?  

(Ex:  <input type="text" name="New Title" ID="SQLBookLibs"/>
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of programmher
programmher

ASKER

Thank you Guru_Sami.