Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have added a GridView to my web form and I want to retrieve a value from it during runtime.

The gridview is located inside an UpdatePanel. I set the AutoGenerateSelectButton property to true. But when I click on an auto generated button it doesn't fire any events. The buttons are like disabled but they are not.

Please help me to resolve this.

Thanks in advance.
Have a nice day!
Posted

 hi ,
you can use loop .

C#
foreach (GridViewRow item in GridView1.Rows)
       {
           string test= item.Cells[2].Text;
       }
 
Share this answer
 
C#
foreach (GridViewRow item in GridView1.Rows)
       {
           string str= item.Cells[i].Text;
       }


Or
you can add a ItemTemplate to Rows and add a Button to Template.Add Bind the parameter "CommandName " and "CommandArgument".
C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Detail")
            {
                e.CommandArgument.ToString();
            }
}
 
Share this answer
 
v2
Use rowcommand event
C#
int index = Convert.ToInt32(e.CommandArgument);
               GridViewRow row = GridView1.Rows[index];
               lblassinmentno.Text = row.Cells[1].Text;
 
Share this answer
 
Hiiiii !!!!!!

I can understand your question. But think about what is the purpose of updatepanel?
Updatepanel is ajax control. So ajax control not post back any data to server. That's why your button does not work. if you are not using updatepanel that your gridview event should be fire and data post back to server.

Your simply answer is that you should fine some java script for call update panel event.









Thank You.
Patel Azharuddin
Software Engineer.
India
Phone: +919998392908
 
Share this answer
 

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