Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        con.Open();
        PlaceHolder1.Controls.Clear();
      
        if (RadioButton1.Checked == true)
        {
            SqlDataReader r1 = default(SqlDataReader);
            SqlCommand cmd = new SqlCommand("Select * from userdet where username  like N'%" + TextBox1.Text + "%'", con);
            cmd.Parameters.AddWithValue("@username", TextBox1.Text);
            r1 = cmd.ExecuteReader();
           /* if (r1.Read())
            {
                Session["un"] = TextBox1.Text;
                Response.Redirect("sampleselect.aspx");
            }
            else
            {
                Label1.Text = "User not found";
            }*/
             int count = 1;
             Table tbl = new Table();
             PlaceHolder1.Controls.Add(tbl);
                   
           do
            {
               
                
               while (r1.Read())
                {
                   
                    for(int i=0;i<count;i++)
                    {
                        TableRow tr = new TableRow();
                         tr.BorderWidth.Equals(10);
                     //  for(int j=0;j<3;j++)
                    //   {
                            TableCell tc = new TableCell();
                            TableCell tc1 = new TableCell();
                            TableCell tc2 = new TableCell();
                           
                           
                           TextBox txtBox = new TextBox();
                            TextBox txtBox1 = new TextBox();
                          //  TextBox txtBox2 = new TextBox();
                            LinkButton lnkbutton = new LinkButton();//Response.Write(r1.GetString(0) + "<br>");
                          
                            txtBox.Text = r1[0].ToString();
                            txtBox1.Text = r1[13].ToString();
                            //txtBox2.Text = r1[1].ToString();
                            lnkbutton.Text = "edit";
                           
                                Session["un"] = txtBox.Text;
                                // Session["un1"] = txtBox1.Text;
                                lnkbutton.PostBackUrl = "../sample/editp.aspx";
                             
                         tc.Controls.Add(txtBox);
                         tc.Controls.Add(txtBox1);
                         tc.Controls.Add(lnkbutton);
                // Add the TableCell to the TableRow
                         tr.Cells.Add(tc);
                         tr.Cells.Add(tc);
                         tr.Cells.Add(tc);
                
        //    }
            // Add the TableRow to the Table
              tbl.Rows.Add(tr);
              }
             // count++; 
                  
                }
            } while (r1.NextResult());


            r1.Close();
            con.Close();
            cmd = null;
            r1 = null;
            con = null;
            //r1.Close();
        }

in the table cells the fetched values are coming but i want to edit the values for the specific username which is diplayed in the table cell. i need help
SQL
while executing depending on the textbox1.text value the data is getting executed but each row data wil get displaying in the table.
like
username emailid option
xxx       aa@gg   Edit 
tat edit is a link button. on clicking tat edit i want to transfer the username in that table which is corresponding to that edit link button
Posted
Updated 24-Feb-10 0:00am
v3

When you are assigning the values to the textboxes, i.e.:
txtBox.Text = r1[0].ToString();
txtBox1.Text = r1[13].ToString();
//txtBox2.Text = r1[1].ToString();


Before doing this, do something like:

// Based on username
if(username.Equals("XYZ"))
{
   //change the value to be displayed
   valueToDisplay = r1[0].ToString() + "_Custom";
}

txtBox.Text = valueToDisplay;
 
Share this answer
 
while executing depending on the textbox1.text value the data is getting executed but each row data wil get displaying in the table.
like
username emailid option
xxx aa@gg Edit
err gg@vvv Edit
tat edit is a link button. on clicking tat edit i want to transfer the username in that table which is corresponding to that edit link button
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900