Get the column value from a DataGrid - VB.NET


I have a datagrid with 6 columns. I am trying to retrieve the value of a column and pass it to a variable. I am not sure what I doing wrong here since the code I am using is not pulling any value from the column.

 This is an example of what I am trying to do.


Dim column_value As String

column_value = DataGrid1.Items(0).Cells.Item(4).Text

Please correct me if I am wrong. 






4/28/2009 3:17:27 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 30

Use a GridView control instead, and access it like this: 

Dim column_value As String
columna_value = testGridView.Rows(0).Cells(0).Text


Please mark as answer if the post helps

static void Swap(ref int a, ref int b)
//Who said it can't be done without a temporary variable?
a = a ^ b;
b = a ^ b;
a = a ^ b;
4/28/2009 4:39:58 PM

Thanks for responding...but can it not be done for a Datagrid?

4/28/2009 5:52:13 PM

.but can it not be done for a Datagrid?

In DataGrid it should be something like:


Dim column_value As String
column_value = DataGrid1.Items(0).Cells(0).Text
'just changed the index of cells and items based on your requirements
You may also try to look at this article about: Accessing Different Controls inside the Datagrid


"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
4/28/2009 6:22:21 PM

Hi Vinz,

Thanks a lot for your help. The article that you mentioned was very helpful. I could finally retrieve the column value.






4/28/2009 7:34:56 PM

Similar Artilces:

Datagrid(.net 1.1) to GridView(.net 2.0) and using the RowUpdating event how to extract the values from the controls.
Ok  This is the settings: I use a Viewgrid with only itemtemplate colums for example. <asp:TemplateField HeaderText="Test"><ItemTemplate><asp:Label id="LBL_Test" text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' runat="server" meta:resourcekey="LBL_TestResource1"></asp:Label></font></ItemTemplate> <EditItemTemplate><asp:TextBox ID="HDN_Test" Text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' Runat="server" meta:resourcekey="HDN_TestResource1" /></EditItemTemplate></asp:TemplateField>  The ...

------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

I am not getting my mail open on my net as net is running
Name: Email: rmbala91atgmaildotcom Product: Firefox Summary: I am not getting my mail open on my net as net is running Comments: My mail is not getting opening. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100401 Firefox/3.6.3 From URL: Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

net send in .net
Hi,  I am trying to execute net send comman in my code. But I am getting "win32 exception unhandled error". Please help me. My code is:Dim psi As New ProcessStartInfo() psi.UseShellExecute = False psi.FileName = "Net send" '  - IP address of a system in my network psi.Arguments = " test" Process.Start(psi)  Thanks in advance! Shwetha Tryu changing   psi.FileName = "Net send" '  - IP address of a system in my network psi.Arguments = " test" to   psi.FileName = "net.exe" '  - IP address of a system in my network psi.Arguments = "Send test"   Hope it helps Hi Shwetha, You just need to do a small modification to your code. Instead of "Net Send" in the place of the filename, give "Net". Change your code as below: Dim psi As New ProcessStartInfo() psi.UseShellExecute = False psi.FileName = "Net" '  - IP address of a system in my network psi.Arguments = "Send test" Process.Start(psi) Thats it! I did the same mistake when I came over a similar situation.   Bye Prabaa Oh! Thank you so much Thank you so much Prabaa....

To .NET or not .NET, that is the question
I'm running WinXP pro 32-bit, meaning I've got the version 1-dot-something of .NET that XP came with. I've been looking for various softwares, and more and more often come across .NET version 2 being prerequisite. No urgency for me re. my questions to this group - so far I have just decided to hit the red X on those download pages - but the desire for this newer version of .NET seems to be growing for me. Firstly, according to my (limited) research, newer .NET versions are inclusive of the previous ones, and the current version seems to be 3.5. So if I go for i...

Net Farmers net
Has anyone been able to access any of the tests at ? I can get the default page but none of the tests appear to be operating over the last several weeks. -- CK I just tested and works as usual!!!Every session TCP_error,because my Shields_guard is intact<<G>> -- Regard: Joh@nnes� 1216771 Ont.Inc. "Nothing is more damaging to a new truth than an old error" "CK" <> wrote in message news:9i45gg$1qa9$ : Has anyone been able to access any of the tests at : http://suicide...

How to make a .NET assembly to control a service which built by .NET?
i need to build a service to be a quota service by .NET but i need to build a .NET assembly to manage the service by web so, how to build a assembly to control it?Parco LeeOwner + Webmaster + System Engineer + Professional ProgrammerSoftDweller Lab (a software laboratory)http://www.softdweller.comA professional laboratory for new technology softwares developing by .NET. You need to build a class that uses a ServiceController. You can attach the servicecontroller to the service, and use it to stop, start, pause etc. it. I have a blog. Perhaps you'd like to rea...

DataWindow.Net a nominee for Best .NET Libraries / Controls Bruce Armstrong [TeamSybase] TeamSybase blogs: Two 3rd party books on developing with PowerBuilder Need code sample? Check out CodeXchange: Preach the gospel at all times. If necessary, use words. - Francis of Assisi --------------------------------------------------------------------- NOTE: If you are using Google to post messages to the newsgroups, you will *no...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

new to .net, need help setting db values from checkbox's then retrieving value to a label control
Hi, Being new to i know this possible i just can't quite get it right!  I need a page with 5 checkbox's that when submitted sets the bit values in DB fields to checked. Then i need another page that retrieves the records of the checkboxes, but instead of having the db pre-set checkboxes on the second page i want it to turn on label web controls depending on if the check box is set.. I hope that makes sense?!! Can anyone point me in the right direction or to a suitable tutorial? Thanks in advance Ben Excellent article here.

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

I'm playing around with fetching things from the CPAN shell here. We have an FTP and an HTTP proxy here. While stepping through things in the debugger, I notice that Net::FTP::new loads $fire from $arg{Firewall} || $ENV{FTP_FIREWALL} || $NetConfig{ftp_firewall} || undef; $fire_type is initialised similarly but %NetConfig is not consulted. Is this deliberate? If not, I suggest the following patch: --- /home/pne/tmp/install/perl-5.8.0/lib/Net/ Sat Jun 1 19:03:20 2002 +++ /home/pne/lib/perl5/5.8.0/Net/ Tue Jan 28 11:29:10 2003 @@ -70,6 +70,7 @@ delete $arg{Po...

Migrate DataGrid .NEt 1.1 to .NEt 2.0
Hi I has just convert my ASP.NET web application from .NET 1.1 to .NEt 2.0 so far there is no problem but my datagrid seems to be acting really weird my datagrid has 3 columns and have paging enabled. When there is one/two row of data. The paging(which shows us the number of page) seems to have a column span of 1)  If i click on the second row of data.... the paging will have the column span of 3 This does not happen if there is more than 2 data   please go to the link for better clarification http://ying...

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

Getting column values that are not shown in the datagrid
Hi,I've had this litte problem several times and couldn't really solve it:void BindGrid(){   ...   string sql = "select ID, Name, AnotherID from ....";   ...}The columns "ID" and "Name" are shown by the DataGrid, the column "AnotherID" is not shown.void OnItem(object Sender, DataGridCommandEventArgs e){   now, here I want to access "AnotherID" for the selected row. someting like "((TextBox)  e.Item.Cells[1].Controls[1]).Text ));" will not work, of course,   since "AnotherID" is not shown in the DataGrid. &nb...

Getting value from a column in a datagrid for record
I have an ASP.NET page with a datagrid on it.  It has an Edit button column on it which I am changing what happens when you click on it.  Originally it opens up editing boxes in the datagrid, I am moving the editing function to an external form.  I have modified the Edit command and am able to get the Index number of the record I clicked on with  e.Item.ItemIndex or DataGrid1.SelectedIndex but the problem is that I need the ID of the record, which is located in a hidden column  (Column 1).  What would be the best means to be able to extract the ID from t...

HI, Can you tell me how can i get the value of a column or columns which row i select ? thanks Patrick Hi,  write the follwing code..  ID=e.Item.Cells[6].Text.Trim(); here we wil get the id which we have selected ...6 is nothing but it is the 6th field we have bounded to the datagrid...   Ramesh   THIS CODE IS NOT HELPING ME, BECAUSE I-M USING VISUAL WEB DEVELOPER THANKS hi , if u are using with then write like this  ID=e.Item.Cells[6].Text.Trim()   Ramesh Can you please be more specific regarding the type of data you...

how to get the value out of the HyperLink column in the datagrid
I need to get the text which is displayed in the hyperlink column. I tried many ways but always it returns empty "". This is little bit of my C# code: foreach(DataGridItem dgi in myDataGrid.Items)             {                 CheckBox myCheckBox = (CheckBox)dgi.Cells[3].Controls[1];                 HyperLinkColumn hyper = (HyperLinkColumn) myDataGrid.Columns[1];          ...

Getting column value from a gridview control
I have a grid view control and has one datakey and other columns. In my grid view I have an Edit Control and a Delete Control. 1) When I press Edit control, I am getting datakey value as expected. But I am not getting other column name i.e. pdf_filename 2) when I press Delete control, I should get the datakey value. But I am not getting I am using c#  Please help me Hi vmk, Could you be a littlemore elaborate? like how have you bound your grid? 1.Columns autogenerated 2.Using TemplateFields 3.Using BoundFields.Regards,NaveenPlease remember to click Mark as Answer on the pos...

Getting the value of a certain column in the datagrid
Its quite simple what I'm trying to do but its never that simple when u don't know how. I just need to get the value of a certain column. noteID = (int) C1WebGrid1.DataKeys[e.Item.ItemIndex]; This lets me get the column id which i use to tell the db that this note is to status is to be set as read, this then moves the row into another grid. Problem is I need to run the read/unread through an if statement so i can toggle the row has read/unread. If I know that it been returned as unread then I toggle it to read and vice versa. I just need to that column value from the grid. ...

How to Get Value from a Column of ItemTemplate of a DataGrid?
in my DataGrid column[5] is a Template Column in Item Template have a Table and Table have 3 columns How to get the Value from the Table in a Item Template   of DataGrid?  thank you string txt = ((TextBox)(datagrid1.FindControl("Control1"))).Text;Sincerely, roy thank you, but I can't really understand ... can you explian more ?  what is Control1 mean?  sorry let me explain my question  A datagrid have a Template Column and in the Template Column have a Table in the Table have many columns, I need to get a v...

HOw to get the control from a ItemTemplate Column of DataGrid
in a DataGrid have a Templated Column  (this Templated Column is Column[5]) and in this Templated Column have a Table How to get the Table in DataGrid's ItemTemplated Column? ( the id of  Table in Templated is Table7)   I think the code may be first I have to  →  DataTable dt = new DateTable() dt = ??  ( have no idea how to let the dt = Table 7)   please help.. thank you very much Are you trying to access the table7 in an event? In which context are you trying to access it ?  - Surya I'm puzzling how to get a value which is in a co...

Getting the value out of the Template Column in Datagrid
)'> How can I get the Value of the BatchID. )'><ItemTemplate>                                                                                 <%# DataBinder.Eval(Container.DataItem, "BatchID") %>              ...

NPV (Net Present Value) Calculation
Has anyone developed (and care to share) the PB code to determine the Net Present Value, similar to Excels NPV function? Sandy ...

Web resources about - Get the column value from a DataGrid - VB.NET -

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 2/17/2016 4:06:39 PM