troubleshooting Question

In GridView get cell value when check/uncheck CheckBox control for the same row.

Avatar of Mohammad Alsolaiman
Mohammad AlsolaimanFlag for Saudi Arabia asked on
6 Comments2 Solutions237 ViewsLast Modified:
How could I get the value of a cell(Product ID) in Gridview , when clicking checkbox control on the same row of the gridview?
Please help.
my web form code here:
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server"  AllowPaging="True"  PageSize="4" AutoGenerateColumns="False" 
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True"  />
                <asp:TemplateField HeaderText="Product ID">
                        <asp:Label ID="lblProductID" runat="server" Text='<%# Bind("ProductID") %>'></asp:Label>
                <asp:BoundField DataField="Name" HeaderText="Name" />
                <asp:BoundField DataField="Price" HeaderText="Price" />
my C# code here
public partial class EEquestion2 : System.Web.UI.Page
        salesDataContext db = new salesDataContext();
        protected void Page_Load(object sender, EventArgs e)
        private void BindData()
            var myProducts = db.Products;

            if ((myProducts != null) && (myProducts.Count() > 0))
                GridView1.DataSource = myProducts;

my gridview
Tapan Pattanaik
Senior Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros