Solved

Read Text Column GridViewRow Data

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now