Click here to Skip to main content
12,448,003 members (79,828 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: .NET3.0 .NET
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 3:04am
Updated 24-Apr-12 3: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 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 24 Apr 2012
Copyright © CodeProject, 1999-2016
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