Click here to Skip to main content
15,843,031 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi....


In my project...one of the scenario i am using gridview with Checkbox .After adding the checkbox to the gridview as a new column of template filed..no postback was performed by all postback controls..like button.i mean no requst goes to server...i did not get wat happened ...plzz suggest me the solution..for this.


Thanks...,
SriramNidamanuri.
Posted
Updated 24-Apr-12 4:05am
v2

Hi ,
Try this
C#
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        if (((CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1")) is CheckBox)
        {
            using (
                SqlConnection con =
                    new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("UPDATE dbo.cate  SET cate = @cate , chk = @chk  where id  = @id", con);
                cmd.Parameters.AddWithValue("@cate",
                                            ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text);
 
                cmd.Parameters.AddWithValue("@chk",
                                            ((CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1")).Checked);
 
                cmd.Parameters.AddWithValue("@id",
                                            ((Label)GridView1.Rows[e.RowIndex].FindControl("Label1")).Text);
 
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.ExecuteNonQuery();
                cmd.Dispose();
 
                GridView1.EditIndex = -1;
                bind();
            }
        }


Best Regards
M.Mitwalli
 
Share this answer
 
Comments
SriramNidamanuri 25-Apr-12 0:29am    
Hi...sir..

Thanks for ur answer,but i am asking about after adding the checkbox into gridview .... no control out side of grid view perform the postback..i mean..one of the button out of grid ... not work click event of that button.
Mohamed Mitwalli 25-Apr-12 3:28am    
Hi ,
Can you share your code

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