473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

getting at data in gridview cells

I am trying to get access to the data in different rows of my gridview
on a button click, in a similar way to the one I used with my 1.1
datagrids. But the cells always seem to be empty. Here is my code :

protected void btnSubmit_Click(object sender, EventArgs e)
{
//get list of pkcustomerrecords and email addresses, put into
generic list
List<EmailDetailsem = new List<EmailDetails>();

int intPKCustomerRecord;
string strConsultant;
string strEmailAddress;

for (int i = 0; i < GridView1.Rows.Count; i++)
{
if
(((CheckBox)GridView1.Rows[i].FindControl("chkSendEmail")).Checked ==
true)
{
intPKCustomerRecord =
Convert.ToInt32(GridView1.Rows[i].Cells[3].Text);
strConsultant =
Convert.ToString(GridView1.Rows[i].Cells[2].Text);
strEmailAddress =
Convert.ToString(GridView1.Rows[i].Cells[1].Text);

EmailDetails ed = new EmailDetails();
ed.PKCustomerRecord = intPKCustomerRecord;
ed.Consultant = strConsultant;
ed.EmailAddress = strEmailAddress;

em.Add(ed);
}
}

Can anybody help me out?

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
2 1806
On Apr 16, 6:12*am, Mike P <mike.p...@gmail.comwrote:
I am trying to get access to the data in different rows of my gridview
on a button click, in a similar way to the one I used with my 1.1
datagrids. *But the cells always seem to be empty. *Here is my code :

protected void btnSubmit_Click(object sender, EventArgs e)
* * {
* * * * //get list of pkcustomerrecords and email addresses, put into
generic list
* * * * List<EmailDetailsem = new List<EmailDetails>();

* * * * int intPKCustomerRecord;
* * * * string strConsultant;
* * * * string strEmailAddress;

* * * * for (int i = 0; i < GridView1.Rows.Count; i++)
* * * * {
* * * * * * if
(((CheckBox)GridView1.Rows[i].FindControl("chkSendEmail")).Checked ==
true)
* * * * * * {
* * * * * * * * intPKCustomerRecord =
Convert.ToInt32(GridView1.Rows[i].Cells[3].Text);
* * * * * * * * strConsultant =
Convert.ToString(GridView1.Rows[i].Cells[2].Text);
* * * * * * * * strEmailAddress =
Convert.ToString(GridView1.Rows[i].Cells[1].Text);

* * * * * * * * EmailDetails ed = new EmailDetails();
* * * * * * * * ed.PKCustomerRecord = intPKCustomerRecord;
* * * * * * * * ed.Consultant = strConsultant;
* * * * * * * * ed.EmailAddress = strEmailAddress;

* * * * * * * * em.Add(ed);
* * * * * * }
* * * * }

Can anybody help me out?

*** Sent via Developersdexhttp://www.developersdex.com***
Have you seen what contact the Row has?
And why you want to do this?
Dont you have to datasource that you originally used?
Jun 27 '08 #2
On Apr 16, 6:12*am, Mike P <mike.p...@gmail.comwrote:
I am trying to get access to the data in different rows of my gridview
on a button click, in a similar way to the one I used with my 1.1
datagrids. *But the cells always seem to be empty. *Here is my code :

protected void btnSubmit_Click(object sender, EventArgs e)
* * {
* * * * //get list of pkcustomerrecords and email addresses, put into
generic list
* * * * List<EmailDetailsem = new List<EmailDetails>();

* * * * int intPKCustomerRecord;
* * * * string strConsultant;
* * * * string strEmailAddress;

* * * * for (int i = 0; i < GridView1.Rows.Count; i++)
* * * * {
* * * * * * if
(((CheckBox)GridView1.Rows[i].FindControl("chkSendEmail")).Checked ==
true)
* * * * * * {
* * * * * * * * intPKCustomerRecord =
Convert.ToInt32(GridView1.Rows[i].Cells[3].Text);
* * * * * * * * strConsultant =
Convert.ToString(GridView1.Rows[i].Cells[2].Text);
* * * * * * * * strEmailAddress =
Convert.ToString(GridView1.Rows[i].Cells[1].Text);

* * * * * * * * EmailDetails ed = new EmailDetails();
* * * * * * * * ed.PKCustomerRecord = intPKCustomerRecord;
* * * * * * * * ed.Consultant = strConsultant;
* * * * * * * * ed.EmailAddress = strEmailAddress;

* * * * * * * * em.Add(ed);
* * * * * * }
* * * * }

Can anybody help me out?

*** Sent via Developersdexhttp://www.developersdex.com***
Also , consider posting these kind of errors that are relevant
exclusively to ASP.NET to the aspnet NG
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fernando Monteiro | last post by:
Hello, Could anyone please help me ? I've a GridView and I'd like to insert one of the girdview's dataset field as a row tooltip. The grid view is declared like: <asp:GridView...
4
by: Neil | last post by:
I have a gridview which is being populated with no problems. I want to be able to reference the data from the cells in the row but having followed an example on MSDN cannot get any data to be...
0
by: Hongbo | last post by:
Hi, I have a GridView like this one: == <asp:gridview runat="server" id="gvCategory" allowpaging="true" allowsorting="true" alternatingrowstyle-backcolor="#B9DFC7" autogeneratecolumns="false" ...
1
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does...
3
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView =...
3
by: kevinpublic | last post by:
I have an item list for ordered products on a data grid in VS 2003. It's an ASP page running VB behind it. All detail lines display as well as all shipping charges. On the edit screen, we allow...
1
by: rhoenig | last post by:
I have a gridview that is populated from a SortedList. In the gridview I have a text box that the user can update, when they click update I want to remove the entry from the list and readd it with...
7
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all, this is a second post, so apologies, but I never had an answer to my first post (several weeks ago) and I really need some help. I'm using a .Net 2.0 Gridview which is populated using an...
3
by: sailaja71185 | last post by:
Here is my code: using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.