Find button not bringing selected author's name to the top of the grid - Updated Code

I have updated a process that needs to allow the user to click a button and have the grid reload with the selected author's name at the top of the grid. The grid does refresh when I click the button but the author's name that is selected does not appear at the top of the grid. What do I need ot change or include to make the selected author's name display at the top of the grid?

Here is my code:

The button tag within the form and the field the users begin keying the author's name:

<asp:TextBox runat="server" ID="txtAuthors" Text='<%# Bind("AuthorName") %>'/>      
   <ajaxToolkit:AutoCompleteExtender ID="autoAuthor" runat="server" DelimiterCharacters="" Enabled="True" ServicePath="~/WebServices/AuthorsWebService.asmx" ServiceMethod="AutoComplete" TargetControlID="txtAuthors" MinimumPrefixLength="3" />             
         <asp:ImageButton runat="server" ID="btnFindAuthor" Height="17px" ToolTip="Find Author" ImageUrl="~/find.png"  CommandArgument='<%# Bind("AuthorID") %>' OnClick="btnFindAuthor"/>

Open in new window


My script that fires the event when the button is clicked:

protected void btnFindAuthor(Object sender, EventArgs e)
 {
    gvAuthors.DataBind();
  } 

Open in new window



My grid within my form:

 <asp:GridView runat="server" ID="gvAuthors" DataSourceID="Libros" DataKeyNames="AuthorID" AutoGenerateColumns="false">
        <Columns>
            <asp:HyperLinkField HeaderText="Author Name" DataNavigateUrlFormatString="~/Authorr.aspx?id={0}" DataNavigateUrlFields="AuthorID" DataTextField="AuthorName" />                
        </Columns>

Open in new window


What do I need ot change or include to make the selected author's name display at the top of the grid? The page does not log any scripting errors.
programmherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Johny BravoCommented:
>>selected author's name display at the top of the grid?

Where do you wish to display the selected author name ?

Not able to understand. Can you please explain.

Thanks
0
Kamal KhaleefaInformation Security SpecialistCommented:
if u want once you click on the author name write a code at the grid view row command

to get the value of the author name and display it at the top in a label or a textbox
0
programmherAuthor Commented:
The results of the authors are displayed in the grid.   The main librarian wants the members to enter part of the author's name in the text box, click the find authors button, and all the authors with that name display at the top of the grid.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Johny BravoCommented:
You need to search in the table for the author name entered by the user in textbox.

protected void btnFindAuthor(Object sender, EventArgs e)
 {
//SqlConnection
//SqlCommand Select * from Authors where AuthName like txtAuthor.Text + '%';
//SqlDataAdapter
//Dataset
//da.Fill(ds)

    gvAuthors.DataSource = ds;
    gvAuthors.DataBind();
  }
0
programmherAuthor Commented:
Johnny_Bravo1,

After implementing your suggested code, I got this error when clicking the button to display the grid with my selected authors' name(s) at the top:

Both DataSource and DataSourceID are defined on 'gvAuthors'.  Remove one definition.
0
Johny BravoCommented:
Are you using SqlDataSource?

Same Gridview can't be bind from both SqlDataSource and DataSet.

SqlDataSource1.SelectCommand = "Your Select Command";
SqlDataSource1.DataBind();
GridView1.DataBind();
0
programmherAuthor Commented:
Yes, I am using SQLDatasource.    The page was written using SQLDatasource and I was told that is the standard this shop follows.
0
Johny BravoCommented:
Try this code,

Replace SqlDataSource1 with the your SqlDataSource Id.

SqlDataSource1.SelectCommand = "Your Select Command";
SqlDataSource1.DataBind();
GridView1.DataBind();
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.