Solved

Read Text Column GridViewRow Data

Posted on 2015-02-02
2
217 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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