473,324 Members | 2,535 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,324 software developers and data experts.

How do I input data into specific cells in a datagrid

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 2583
RhysW
70
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
para hacer eso lo mas comodo es usar el evento "RowDataBound" 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
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...
2
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...
6
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...
2
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...
3
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. ...
1
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...
1
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,...
4
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...
2
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...
4
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.