Click here to Skip to main content
15,910,411 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
int i;
    protected void Bindddl_Click(object sender, EventArgs e)
    {


        foreach (GridViewRow row in GridView1.Rows)
        {

            System.Web.UI.WebControls.CheckBox chkRow = (row.Cells[i].FindControl("chkRow") as CheckBox);
            if (GridView1.Rows.Count > 0)
            {

                for (i = 0; i < GridView1.Rows.Count; i++)
                {
                    if (chkRow.Checked)
                    {

                        TextBox txtjob1 = (TextBox)GridView1.Rows[i].FindControl("txtjob1");

                        txtjob1.Text = DDLSelJob.SelectedItem.Text;
                    }
                    else
                    {

                        //TextBox txtjob1 = (TextBox)GridView1.Rows[i].FindControl("txtjob1");
                        //txtjob1.Text = "";
                    }
                }

            }
        }


    }
Posted
Updated 29-May-14 1:34am
v2

1 solution

C#
protected void Bindddl_Click(object sender, EventArgs e)
{
  int i = 0;


    foreach (GridViewRow row in GridView1.Rows)
    {

        System.Web.UI.WebControls.CheckBox chkRow = (row.Cells[i].FindControl("chkRow") as CheckBox);
        if (GridView1.Rows.Count > 0)
        {

            for (i = 0; i < GridView1.Rows.Count; i++)
            {
                if (chkRow.Checked)
                {

                    TextBox txtjob1 = (TextBox)GridView1.Rows[i].FindControl("txtjob1");

                    txtjob1.Text = DDLSelJob.SelectedItem.Text;
                }
                else
                {

                    //TextBox txtjob1 = (TextBox)GridView1.Rows[i].FindControl("txtjob1");
                    //txtjob1.Text = "";
                }
            }

        }
       i++; // your first forloog is not incrementing the i value and by default your i    value is 0 u need to increment the i value at the end of your foreach loop.
    }


}
 
Share this answer
 
Comments
safihur Rahuman 29-May-14 8:37am    
ya i forget to increment the value. now its works fine thks you...,

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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