Tuesday, 17 April 2012

How to Find value in textbox through gridview checkbox.?

Here i am describing that how to find value in textbox through Gridview checkbox in asp.net application .I am writing to code here click event . you can learn easy ... 




Here we will write to code on .cs page 

protected void bt5_Click(object sender, EventArgs e)

    {

        TextBox2.Text = String.Empty;

        foreach (GridViewRow row in GridView1.Rows)

        {

            if (((CheckBox)row.FindControl("chk1")).Checked)

            {

                foreach (TableCell cell in row.Cells)

                {

                    if (cell is DataControlFieldCell

                        && ((DataControlFieldCell)cell).ContainingField is BoundField

                        && ((BoundField)((DataControlFieldCell)cell).ContainingField).DataField == "Email_id")

                    {

                        TextBox2.Text = String.Format("{0}{1}{2}",

                            TextBox2.Text,

                            TextBox2.Text == String.Empty ? String.Empty : " ",

                            cell.Text);

                    }

                    if (cell is DataControlFieldCell && ((DataControlFieldCell)cell).ContainingField is BoundField && ((BoundField)((DataControlFieldCell)cell).ContainingField).DataField == "Alt_email")

                    {

                        TextBox2.Text = String.Format("{0}{1}{2}", TextBox2.Text,

                        TextBox2.Text,

                        TextBox2.Text == String.Empty ? String.Empty : "; ",

                        cell.Text);

                    }



                }

            }

        }

    }

No comments:

Post a Comment

What is ASP.NET? Components of ASP.NET

ASP.Net Definition -It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET i...