Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 21st, 2006, 05:59 AM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to fukchai2000
Default Data Binding works but why no value?

hi guys,

I try to write a simple data binding function.
I create a RadioButtonList and i connect to the database and bind the Radio with the DataTable that I got from DataSet.

and I create a print button and i want to fill the lblDisplay with the selected value from the radio. somehow, the selectedIndex from the radio is -1.
Can somebody help me plz...here is the code.

    private void Page_Load(object sender, System.EventArgs e){
     // Put user code to initialize the page here
      string conn = "Persist Security Info=false;database=my_data;uid=my_user;pwd=my_pas s;host=localhost";
      string cmd = "Select * From Visitors";

      MySqlDataAdapter adapter = new MySqlDataAdapter(cmd,conn);
      DataSet data = new DataSet();
      adapter.Fill(data,"Visitors");

      DataTable Visitors = data.Tables["Visitors"];
      rbVisitor.DataSource = Visitors; //i called my radiolist with rbVisitor

      rbVisitor.DataValueField = "vistID";
      rbVisitor.DataTextField = "vistName";
      rbVisitor.DataBind();

      if (!IsPostBack){
        rbVisitor.SelectedIndex = 0;
      }
    }

    private void btnPrint_Click(object sender, System.EventArgs e)
    {
      lblDisplay.Text = rbVisitor.SelectedItem.Text.ToString(); //this part give no value, It print out OK though on the screen
    }

thanks








Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Binding - Editing GridView Row Data desk_star BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 7 December 30th, 2007 11:07 AM
data binding g2000 ASP.NET 2.0 Basics 0 January 13th, 2006 03:36 PM
Data Binding Prashant.k.m Visual Studio 2005 0 April 21st, 2005 06:54 AM
Binding to Filtered Data (or Data subsets) gdbjohnson C# 8 August 27th, 2004 01:59 PM
Program works, but no data being displayed bebe XML 0 October 14th, 2003 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.