Note that there are some explanatory texts on larger screens.

plurals
  1. POAuthorID not being passed to redirect string
    primarykey
    data
    text
    <p>I have a text box that I need to pass the <code>authorid</code> into a hidden field that matches the selected author. I then need to pass that <code>authorID</code> to the response.redirect url so the detailed authors page opens with that author's biography information when the button is clicked.<br> Below is my code but it does not work.<br> How can I get my button to work so the correct authorid is passed everytime the author's name is selected?</p> <pre><code>ImageButton btnFindAuthors = sender as ImageButton; HiddenField myhiddenfield = btnFindAuthors.NamingContainer.FindControl("hiddenID") as HiddenField; int myID = Convert.ToInt32(myhiddenfield.Value); Response.Redirect(String.Format("~/Authors_Detail.aspx?id=" + myhiddenfield)); </code></pre> <p>Markup:</p> <pre><code>&lt;asp:TextBox runat="server" ID="txtAuthors" Text='&lt;%# Bind("AuthorName") %&gt;' /&gt; &lt;asp:ImageButton runat="server" ID="btnFindAuthors" OnClick="btnFindAuthors"/&gt; &lt;ajaxToolkit:AutoCompleteExtender ID="fndAuthors" runat="server" DelimiterCharacters="" Enabled="True" ServicePath="~/WebServices/AuthorsWebService.asmx" ServiceMethod="AutoComplete" TargetControlID="txtAuthors" MinimumPrefixLength="3" /&gt; &lt;asp:HiddenField ID="hiddenID" runat="server" Value='&lt;%#Eval("AuthorID") %&gt;' /&gt; </code></pre> <p>Author Id:</p> <pre><code>&lt;asp:SqlDataSource runat="server" ID="sqlAuthors" ConnectionString="&lt;%$ ConnectionStrings:Libros %&gt;" ProviderName="&lt;%$ ConnectionStrings:Libros.ProviderName %&gt;" SelectCommand="SELECT * FROM Authors WHERE AuthorName LIKE ('%' + @Authorname + '%') ORDER BY AuthorName" &lt;selectParameters&gt; &lt;asp:ControlParameter ControlID="txtAuthors" Name="authorname" /&gt; &lt;/selectParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload