AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > Another question

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 6/6/2006
Subject: Another question

Question
Hi Syed,

I have another question for you. My project requires me now to add an additional GridView to the one I already had. So originally I had a dropdownlist which upon selecting a state brought up author information GridView1. Now on GridView1 I'm required to add buttons next to each author id, so that upon clicking the button, the titles that the selected author wrote will display on a new GridView2. I have been able to get linkbuttons on the GridView1 for each author. However, when I click a button GridView2 does not appear. Would you happen to know how to get it to appear? So far I have done this:

1. I have written a custom SQL statement for      GridView2 so that titles can be called upon selecting an author:

select * from titles where title_id IN (select title_id from titleauthor where au_id =@au_id)

2. I have written function to call the information from GridView1 and display it in GridView2:


   Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
       Session("au_id") = e.CommandArgument
       If GridView2.Rows.Count > 0 Then
           GridView2.Visible = True
       End If
   End Sub

3. Last of all, under GridView1 Tasks I went to the edit columns link and selected au_lname, au_fname, city, state and a button field from the available fields box and added it to the selected fields box. After that I set the button field into a Template Field. After doing this I went into edit templates link and selected edit databindings under the linkbutton tasks menu. In this menu I custom binded both the CommandArgument and Text properties of the linkbutton with the code expression Eval("au_id").

Hope that helps. I would be most grateful for any advice you could offer. This is my final hurdle on this project! Thanks.

Sachin

Answer
Rather than what you are doing I would simply add a column au_id in GridView1 as the first column which is also hidden.

And add a Select Button to GridView1.

On GridView1.SelectedIndexChanged I would write the following code:

If Gridview1.selectedItem is nothing then exit sub
au_id = GridView1.SelectedItem.cells(0).text
and then au_id variable where ever I want to coz it now contains the authoriID the user has selected.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.