Solved

Read Text Column GridViewRow Data

Posted on 2015-02-02
2
215 Views
Last Modified: 2015-02-09
Hello Experts,
I am trying to read a GridView in c#.  Till Cell(3), I am able to read the data.  But, Cell[4] shows empty, which is a text field contains date.  This filed is Edit/Update field.  Any idea, why I am not able get the data?  Below is the code.

Thank you in advance!

    string Id, Name, FNumber, FName, FValue;
    foreach (GridViewRow Item in grdImportView.Rows)
    {
        PId = Item.Cells[0].Text;
        PName = Item.Cells[1].Text;
        FNumber = Item.Cells[2].Text;
        FName = Item.Cells[3].Text;
        FValue = Item.Cells[4].Text;
    }
0
Comment
Question by:RadhaKrishnaKiJaya
2 Comments
 
LVL 17

Accepted Solution

by:
John Gates earned 500 total points
ID: 40585224
Yes you have to reference that control:

foreach (GridViewRow row in <yourgridview>.Rows) {
      string dRow = row.DataItemIndex;
      TableCell SECCell = row.Cells(7);
      //The TextBox is the 0th element of the Controls collection.
      TextBox SECBox = (TextBox)SECCell.Controls(0);

}

This way you are telling the system to give you the value in the actual textbox control

Hope this helps!

-D-
0
 

Author Closing Comment

by:RadhaKrishnaKiJaya
ID: 40599363
Thank you John.  The above code worked.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question