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

Q: datagrid values with column name

Hello,
string colVal =((TextBox)e.Item.Cells[i].Controls[0]).Text;

this is how I reach column value in a grid:
how can I reach with the column name?
some value should be int, some date, how should I read them?
Thanks,
Jim.

Nov 19 '05 #1
4 1914
Make a simple utility function that will take a column name as a parameter,
loop through the Columns collection and return the index of the column with
matching name.

Eliyahu

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hello,
string colVal =((TextBox)e.Item.Cells[i].Controls[0]).Text;

this is how I reach column value in a grid:
how can I reach with the column name?
some value should be int, some date, how should I read them?
Thanks,
Jim.

Nov 19 '05 #2
can you give me example?

"Eliyahu Goldin" wrote:
Make a simple utility function that will take a column name as a parameter,
loop through the Columns collection and return the index of the column with
matching name.

Eliyahu

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hello,
string colVal =((TextBox)e.Item.Cells[i].Controls[0]).Text;

this is how I reach column value in a grid:
how can I reach with the column name?
some value should be int, some date, how should I read them?
Thanks,
Jim.


Nov 19 '05 #3
C#:
static public System.Web.UI.WebControls.TableCell CellByName
(System.Web.UI.WebControls.DataGridItem item, string name)
{
System.Web.UI.WebControls.DataGrid grid = item.Parent.Parent as
System.Web.UI.WebControls.DataGrid;
for (int col = 0; col < item.Cells.Count; col++)
if (grid.Columns[col].HeaderText == name)
return item.Cells[col];
// not found
return null;
}
--
Eliyahu

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
can you give me example?

"Eliyahu Goldin" wrote:
Make a simple utility function that will take a column name as a parameter, loop through the Columns collection and return the index of the column with matching name.

Eliyahu

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hello,
string colVal =((TextBox)e.Item.Cells[i].Controls[0]).Text;

this is how I reach column value in a grid:
how can I reach with the column name?
some value should be int, some date, how should I read them?
Thanks,
Jim.


Nov 19 '05 #4
Hi Jim:

You can't reach the control by column name, but you could use
FindControl and fetch what you need with the Control ID. See:
http://odetocode.com/Articles/116.aspx

Also, you can look at the Convert class to convert objects into
DateTime objects and such.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 7 Apr 2005 06:17:03 -0700, JIM.H.
<JI**@discussions.microsoft.com> wrote:
Hello,
string colVal =((TextBox)e.Item.Cells[i].Controls[0]).Text;

this is how I reach column value in a grid:
how can I reach with the column name?
some value should be int, some date, how should I read them?
Thanks,
Jim.


Nov 19 '05 #5

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

Similar topics

0
by: Bob Rosen | last post by:
The description given in "Customizing Items Dynamically in the DataList or DataGrid Web Server Control" (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbCode/...
3
by: Dmitry Akselrod | last post by:
Hi, I am using a standard .NET 1.0 Datagrid. Actually, I am using two, bound to a master-detail relationship. Both DataGrids are bound to a datasource. I have the MSDN version of the...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
6
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
4
by: Pacific Design Studios | last post by:
I have a DataGrid on Form1 that displays a small amount of information about employees. On Form2 I want to have all the data displaying in text boxes about the employee selected in the datagrid on...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
1
by: nate axtell | last post by:
In VB .NET I load the contents of an Excel or comma seperated values file into a dataGrid (via a datatable). One of the columns has a comma in the name of the column. So for the comma separated...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
0
by: sathyan8294 | last post by:
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label and textboxes are avilable to save the entering...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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...
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,...

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.