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 April 26th, 2006, 02:52 AM
Authorized User
Join Date: Dec 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel
Default Databind in TextBox

Hi Experts,

I am using Two Array of Text Boxes defined in the Class as :

//Data Members
protected System.Web.UI.WebControls.TextBox [] txtSpeakerName;
protected System.Web.UI.WebControls.TextBox [] txtSpeakerNumber;

I am not able to load the TextBoxes text field, its coming blank string.

So either the binding is not proper or dataset is not filled.

Guide me how to bind the "System.Web.UI.WebControls TextBox" ?????

//Code inside the Page_Load()
int speakerPort = 2;
int QAId = Int32.Parse(Request.QueryString["QAId"]);
string sConnection ="server=xxxxxxxxxxxx;database=xx;uid=xyz;pwd=uv;" ;
// Load the Speakerdetails from "QASpeakerDetails" Table
SqlConnection connSQL = new SqlConnection(sConnection);
DataSet dsSpeakerDetails = new DataSet();

string strSqlQuery = "Select SpeakerName, SpeakerNumber From QASpeakerDetails Where QAid =" + QAId;

SqlDataAdapter daSpeakerDetails = new SqlDataAdapter(strSqlQuery, connSQL);

daSpeakerDetails.Fill(dsSpeakerDetails, "QASpeakerDetails");

txtSpeakerName = new TextBox[5];
txtSpeakerNumber = new TextBox[5];

for(i = 1; i <= speakerPort; i++)
        // Create and Add Text for Speaker Name
    txtSpeakerName[i-1] = new TextBox();
    txtSpeakerName[i-1].ID = "speakerName_" + i.ToString();

    // Create and Add Text for Speaker Number
    txtSpeakerNumber[i-1] = new TextBox();
    txtSpeakerNumber[i-1].ID = "speakerNumber_" + i.ToString();


Old April 26th, 2006, 05:51 AM
Authorized User
Join Date: Dec 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel

Hi all,

i got the the half solution....

this.txtSpeakerName[i-1].Text = Convert.ToString(DataBinder.Eval(dsSpeakerDetails, "Tables[QASpeakerDetails].DefaultView.[" + i + "-1].SpeakerName"));

Only thing i need to add this above statement before

But here i am getting only one Exception in the second string parameter i am passing in Eval(container, expr)

""'System.Data.DataView' does not allow indexed

Can anybody tell me the reason....

below statement is working with indexing.

this.txtSpeakerName[i-1].Text = Convert.ToString(DataBinder.Eval(dsSpeakerDetails, "Tables[QASpeakerDetails].DefaultView.[0].SpeakerName"));


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databind DarkForce ASP.NET 2.0 Basics 5 January 25th, 2011 12:04 PM
About the Databind() kuuy BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 1 November 15th, 2006 12:56 PM
How to databind a textbox to a dataset field aven ASP.NET 2.0 Basics 1 January 26th, 2006 11:39 PM
Can't get RadioButtonlist with databind nayalksrs123 .NET Web Services 0 January 15th, 2005 06:29 AM
DataBind Problem liorlankri ADO.NET 3 November 2nd, 2004 04:13 PM

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