Solved

Read Text Column GridViewRow Data

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

24 Experts available now in Live!

Get 1:1 Help Now