#StackBounty: #c# #asp.net #gridview How to loop through each and every row, put value in gridview column cells

Bounty: 50

i have gridview with 3 columns and 100 rows. and one submit button out of gridview.

here first 2 column is bounded field and 3rd one is Label (templatefield) .

Now, I want to change status of 3rd column and display it to gridview when loop run.

i want to

when i=0 then i want to change label's value to "SUCESS" and display on Gridview,
     i=1 then i want to change label's value to "SUCESS" and display on Gridview,
     and so on till i=100.

Gridview

<asp:GridView ID="GvCategoryLive" runat="server" AutoGenerateColumns="False" EmptyDataText="No Records Found !"  >
  <Columns>
      <asp:BoundField DataField="UnitName" HeaderText="Unit Name" />
      <asp:BoundField DataField="CreateDate" HeaderText="Created Date" />
      <asp:TemplateField HeaderText="Status">
          <ItemTemplate>
              <asp:Label ID="UnitMesurement_Id" runat="server" Text=""></asp:Label>
          </ItemTemplate>
      </asp:TemplateField>
  </Columns>
</asp:GridView>

I am trying something like this

 protected void btnSave_Click(object sender, EventArgs e)
{
    if (btnSave.Text == "Save")
    {
        for (int i = 0; i < GvCategoryLive.Rows.Count; i++)
        {
            System.Threading.Thread.Sleep(9000);
            GvCategoryLive.Rows[i].Cells[2].Text = "Success";

        }
    }

}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.