Click here to Skip to main content
11,411,494 members (66,094 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.0
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 24-Apr-12 4:04am
Edited 24-Apr-12 4:05am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi ,
Try this
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
  Permalink  
Comments
SriramNidamanuri at 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 at 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)

  Print Answers RSS
0 OriginalGriff 223
1 Sascha Lefévre 155
2 Sergey Alexandrovich Kryukov 149
3 ProgramFOX 90
4 Dave Kreskowiak 90
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 7,128
2 Maciej Los 3,440
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 24 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100