dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Problem with bind data in textbox

  1. #1
    Join Date
    Oct 2006
    Posts
    123

    Problem with bind data in textbox

    hi,
    i note that when i retrieve data and bind it to textbox that when i want to bind to each textbox i do the same thing , so i think to make method where i pass array of the name of textbox and it will bind automatic for each textbox and here is what i try to do

    Code:
     //Step 1 :
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "student_SelectAll";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = cn;
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
    
                //Step 2 :
                TextBox [] txtb={textBox1,textBox2,textBox3,textBox4,textBox5,textBox6,textBox7,textBox8};
    
                //Step 3:
                IDataParameter[] param = adapter.GetFillParameters();
                for (int i = 0; i <param.Length; i++)
                {
                    cmd.Parameters.Add(param[i].ParameterName,param[i].DbType).Value = txtb[i].Text;
                }
    so who i can do something like this ?

  2. #2
    Join Date
    Dec 2007
    Location
    South Africa
    Posts
    263

    Resolved Re: Problem with bind data in textbox

    I think i gave you an answer when you posted it in codeProject
    Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)