Solved

pass dataValueField in a querystring

Posted on 2006-11-18
2
1,063 Views
Last Modified: 2010-05-18
How do I pass the DataValueField in a bulleted list via a QueryString to my details page, EmploymentDetails.aspx, so I can display all the data.

Here is my method in the data access object class file that returns the records from the database:

public static ArrayList GetList()
        {
            ArrayList a = new ArrayList();
            try
            {

                // Create DataBase Instance
                Database db = DatabaseFactory.CreateDatabase("conn");
                DbCommand dbCommand = db.GetStoredProcCommand("dbo.spGetEmploymentOpportunities");
                using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                {
                    while (dataReader.Read())
                    {
                        EmploymentOpportunity e = new EmploymentOpportunity();
                        e.ID = (int)dataReader["employment_opportunity_id"];
                        e.title = dataReader["title"].ToString();
                        e.location1 = dataReader["location"].ToString();
                        e.responsabilities = dataReader["responsibilities"].ToString();
                        e.physicalRequirements = dataReader["education_experience"].ToString();
                        e.educationExperience = dataReader["physical_requirements"].ToString();
                        e.salary = dataReader["salary_info"].ToString();
                        e.contactEmail = dataReader["contact_email"].ToString();
                       
                        a.Add(e);
                    }
                }
            }
            catch (Exception ex)
            {
                //Response.Write(ex.ToString());
            }
            return a;
        }

Here is my bulleted list control:

<asp:BulletedList ID="BulletedList1" runat="server" CssClass="ulnobullets" DisplayMode="HyperLink">
    </asp:BulletedList>

Here is the page load method in the code-behind:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {  
            BulletedList1.DataSource = EmploymentOpportunityDAO.GetList();
            BulletedList1.DataValueField = "ID";
            BulletedList1.DataTextField = "title";
            BulletedList1.DataBind();
        }
    }

I need to set this line to pass the value via a querystring.  How do I accomplish this?

BulletedList1.DataValueField = "ID";


Any help is appreciated.
Thanks.
0
Comment
Question by:-Dman100-
2 Comments
 
LVL 9

Accepted Solution

by:
kraffay earned 500 total points
ID: 17973024
Are you asking how to get the selected value of the bulleted list talked on to a qry string?

If so, there is selectedIndex_changed (check me on that) event of the list that fires when a user makes a selection.  You can have your list auto-post back and then grab the selectedValue property of the list, then redirect to a url that you build dynamically.

protected void mylist_selectedindex_changed(yada...yada)
{

      string ID = mylist.selectedvalue;
      response.redirect("EmploymentDetails.aspx?ID=" + ID);  

}


0
 

Author Comment

by:-Dman100-
ID: 17973087
Hi kraffy,

Thanks for replying to my post.

Yes, I do want to pass the selected value of the bulleted list in a querystring.

I checked the events for the bulleted list, but there isn't a selectedIndex_changed event.  I believe that is an event for a dropdown control.

I thought I could build the querystring using:

BulletedList1.DataValueField = "EmploymentDetails.aspx?ID=" + ID;

But, that doesn't work.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now