473,788 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 pkcustomerrecor ds and email addresses, put into
generic list
List<EmailDetai lsem = new List<EmailDetai ls>();

int intPKCustomerRe cord;
string strConsultant;
string strEmailAddress ;

for (int i = 0; i < GridView1.Rows. Count; i++)
{
if
(((CheckBox)Gri dView1.Rows[i].FindControl("c hkSendEmail")). Checked ==
true)
{
intPKCustomerRe cord =
Convert.ToInt32 (GridView1.Rows[i].Cells[3].Text);
strConsultant =
Convert.ToStrin g(GridView1.Row s[i].Cells[2].Text);
strEmailAddress =
Convert.ToStrin g(GridView1.Row s[i].Cells[1].Text);

EmailDetails ed = new EmailDetails();
ed.PKCustomerRe cord = intPKCustomerRe cord;
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 1815
On Apr 16, 6:12*am, Mike P <mike.p...@gmai l.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 pkcustomerrecor ds and email addresses, put into
generic list
* * * * List<EmailDetai lsem = new List<EmailDetai ls>();

* * * * int intPKCustomerRe cord;
* * * * string strConsultant;
* * * * string strEmailAddress ;

* * * * for (int i = 0; i < GridView1.Rows. Count; i++)
* * * * {
* * * * * * if
(((CheckBox)Gri dView1.Rows[i].FindControl("c hkSendEmail")). Checked ==
true)
* * * * * * {
* * * * * * * * intPKCustomerRe cord =
Convert.ToInt32 (GridView1.Rows[i].Cells[3].Text);
* * * * * * * * strConsultant =
Convert.ToStrin g(GridView1.Row s[i].Cells[2].Text);
* * * * * * * * strEmailAddress =
Convert.ToStrin g(GridView1.Row s[i].Cells[1].Text);

* * * * * * * * EmailDetails ed = new EmailDetails();
* * * * * * * * ed.PKCustomerRe cord = intPKCustomerRe cord;
* * * * * * * * ed.Consultant = strConsultant;
* * * * * * * * ed.EmailAddress = strEmailAddress ;

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

Can anybody help me out?

*** Sent via Developersdexht tp://www.developersd ex.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...@gmai l.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 pkcustomerrecor ds and email addresses, put into
generic list
* * * * List<EmailDetai lsem = new List<EmailDetai ls>();

* * * * int intPKCustomerRe cord;
* * * * string strConsultant;
* * * * string strEmailAddress ;

* * * * for (int i = 0; i < GridView1.Rows. Count; i++)
* * * * {
* * * * * * if
(((CheckBox)Gri dView1.Rows[i].FindControl("c hkSendEmail")). Checked ==
true)
* * * * * * {
* * * * * * * * intPKCustomerRe cord =
Convert.ToInt32 (GridView1.Rows[i].Cells[3].Text);
* * * * * * * * strConsultant =
Convert.ToStrin g(GridView1.Row s[i].Cells[2].Text);
* * * * * * * * strEmailAddress =
Convert.ToStrin g(GridView1.Row s[i].Cells[1].Text);

* * * * * * * * EmailDetails ed = new EmailDetails();
* * * * * * * * ed.PKCustomerRe cord = intPKCustomerRe cord;
* * * * * * * * ed.Consultant = strConsultant;
* * * * * * * * ed.EmailAddress = strEmailAddress ;

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

Can anybody help me out?

*** Sent via Developersdexht tp://www.developersd ex.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
1115
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 ID="grdLista" runat="server" DataSourceID="sdsList"
4
35620
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 displayed in a text box no matter which cell index I provide. I tried a row of code that successfully displays the rowindex of the selected row. The code with comments is below:
0
1451
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" pagesize="20" width="550px" datasourceid="prodList"> <headerstyle backcolor="#B9DFC7" /> <columns> <asp:templatefield>
1
7014
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 anyone have any idea how to get this to work? below is the code. Please bear in mind that the function is actually located in a seperate class file from the page that actually returns the grid. ---code for function that returns the grid, this is...
3
15317
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView = (DataRowView)e.Row.DataItem; // Retrieve the value for the current row.
3
2342
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 them to cancel individual line items. We have the 'Cancel' button enabled for the line items of the datagrid. However, I would like to hide that button for the shipping charges. We don't want them cancelling their shipping fees, after all. ...
1
1874
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 the updated item. My problem is when I try to get the text that is in the cells of the gridview it returns nothing. I remove the item from the list and that works fine so I know it's getting the proper row. Here's my code. I found most of...
7
11061
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 ObjectDataSource which calls on a method in a class. This all works fine. The Gridview has a select button automatically generated. When the user presses this I want to be able to take the data from the selected record and use it. However...
3
1708
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
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.