473,809 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I input data into specific cells in a datagrid

1 New Member
I am new to C# and am not experienced in creating complex methods. I need to create a class that will input data into a DataGrid with set number of columns but an unknown number of rows. This method would need to use either SetText or TypeKeys in the designated cells.
column examples:
column 1: Phase ID
column 2: Cost Code ID
column 3: Number of Units
column 4: Expenses
column 5: Revenues

I know that when I try to declare the cells, it is (column:row). The problem is I am unsure how to populate specific cells (for example: Phase ID, Expenses and Revenue only) with data that is passed into the method. Also the Phase ID and Cost Code ID have a PushButton for a drop list. The DataGrid class doesn't seem to have this functionality. Please help!
Mar 18 '12 #1
2 2598
RhysW
70 New Member
Expand|Select|Wrap|Line Numbers
  1. grd_datagrid.Rows[1].Cells[0].Value = "xyz";
the 1 in the rows[1] means it will select the second row (the first row is rows[0]) the cells[0] means it iwll select the very first cell, the .value allows you change the vlaue of this cell to whatever is in the quotes

you had a long wait for this but thats essentially how you do it! this relies on you knowing what row and cell you want things to go into, there are more complex ways of doing this when you dont know what row or cell you want to put data in but it is doable
Apr 13 '12 #2
Mistica009
1 New Member
para hacer eso lo mas comodo es usar el evento "RowDataBou nd" del datagrid o gridview, donde tienes disponible lo siguiente:

Expand|Select|Wrap|Line Numbers
  1. if (e.Row.RowType == DataControlRowType.DataRow)
  2.             {
  3. DataRowView dataItem = (DataRowView)e.Row.DataItem;
  4. e.Row.Cells[0].Text = "Nuevo valor";
  5.  
  6. }
Apr 13 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3149
by: Grey | last post by:
I have created a asp.net form for user to input data. After input the data, user need to click a button to export the input data to excel for data analysis with excel pivot table function. is it possible to do that?? if so, any sample for me as i am a new in designing pivot table with asp.net million thanks
2
42894
by: Jim B | last post by:
I am new to VB.NET and have a question on validating user input from a Text Box. I'm writing a small program where I want to check the users input data and determine if it's an Integer or a Decimal. I guess I want to go one step further than just checking for IsNumeric. I have searched this Work Groups' database and did not find exactly what I need. I have tried GetType, VarType, and the Val Function using the Text Box data, without...
6
4682
by: shil | last post by:
Hi, I am writing a windows app in .net 2003. I have a datagrid which gets data from a storedprocedure. My question is how can I update the data in the datagrid? I want to call another storedprocedure to update the data in the datagrid. Thanks in advance.
2
1384
by: ameen.abdullah | last post by:
Hi Guys, I have a datagrid which is binded to dataset which is gettting data from xml. Now i need to know if i edit or add data to the datagrid, whats the best possible way to fetch it? .. i need to fetch the data and put it in another xml file to update. Thanks in adv guys
3
1716
by: kingflux | last post by:
Hello, and thank you in advance for any help you can provide. Each line in our datagrid control contains a product number, description, and a textbox for the user to enter a quantity-to-order. Users enter quantities (not necessarily on every line), click the Next button, and continue. Sometimes users return to a previous page, by clicking the Previous button, and see quantities that they did not enter. More often, users return to a...
1
1282
by: sahachinmoy | last post by:
I can select data from a datagrid but i want to know how can i get this selected data from the datagrid to a different place (eg i select a data in datagrid and the selected data will be visible in a text box).
1
3939
by: slph | last post by:
Hello everyone, I am developing an application where allow user to input the data from a given VB form and display the user input to the datagrid at the same time. As I know, datagrid can pull data from given database table. But I would like user to confirm the input data before save them into the database. Is there any way to do that with VB6 datagrid or any alternative? Thanks.
4
1400
by: selvialagar | last post by:
I'm working in vb.net 2003. Now i want to display data in the datagrid.The data is not from the database. Now i am executing ping program. The result will be hostname and time. These two data will be added to the datagrid. How to add them in the datagrid. How to add columns and rows?
2
2046
by: sivasweety | last post by:
I have created a List of contents in a database table which will display in Datagrid window. The user may select one or many data from the Datagrid. If data selected data should be shown in Another datagrid. If a content is not available user may be allowed to add additional 'List of contents'. The addl. data also to be included automatically in that database table. The project is for our deaf association. Advance thanks pl.
4
21348
by: lena1342 | last post by:
Hi Everyone! I tried to insert a picture in specific cells and I have coded a small VBA for Excel 2007. Unfortunately the macro only opens and inserts a picture in the active sheet but it should add the picture in cell B3, H4 and L6 in this sheet. Could you please help me to fix the problem. thx a lot!
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10639
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...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
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
9200
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...
0
6881
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
5550
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...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.