473,394 Members | 1,781 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,394 software developers and data experts.

Datagrid code not working!!

Hi,

Im trying to format my datagrid via some code to make one
column readonly while the other can be edited.
I also tried to change the column header. The problem is
that the code does not seem to be taking effect.

Here is my code. Can anyone please offer me some help?

da = New SqlDataAdapter("SELECT Equipment_Desc, 0 as
Quantity FROM Equipment_Details", Cn)

ds = New DataSet("Equipment")
da.Fill(ds)

DataGridEquip.DataSource = ds.Tables(0)

Dim TSEquip As New DataGridTableStyle()
TSEquip.MappingName = "Equipment"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equipment_Desc"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 110
TCEquipName.ReadOnly = True
TSEquip.GridColumnStyles.Add(TCEquipName)

Dim TCQuantity As New DataGridTextBoxColumn()
TCQuantity.MappingName = "Quantity"
TCQuantity.HeaderText = "Quantity"
TCQuantity.Width = 90
TCQuantity.ReadOnly = False
TSEquip.GridColumnStyles.Add(TCQuantity)
DataGridEquip.TableStyles.Add(TSEquip)
Nov 22 '05 #1
6 1549
I'm no expert, but I think the mapping name for the grid needs to be same as
the table that the data is coming from. Try changing to...

TSEquip.MappingName = "Equipment_Details"
--
For real reply address, lose the cash
www.realuk.co.uk
"Angelina" <an*******@discussions.microsoft.com> wrote in message
news:1d****************************@phx.gbl...
Hi,

Im trying to format my datagrid via some code to make one
column readonly while the other can be edited.
I also tried to change the column header. The problem is
that the code does not seem to be taking effect.

Here is my code. Can anyone please offer me some help?

da = New SqlDataAdapter("SELECT Equipment_Desc, 0 as
Quantity FROM Equipment_Details", Cn)

ds = New DataSet("Equipment")
da.Fill(ds)

DataGridEquip.DataSource = ds.Tables(0)

Dim TSEquip As New DataGridTableStyle()
TSEquip.MappingName = "Equipment"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equipment_Desc"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 110
TCEquipName.ReadOnly = True
TSEquip.GridColumnStyles.Add(TCEquipName)

Dim TCQuantity As New DataGridTextBoxColumn()
TCQuantity.MappingName = "Quantity"
TCQuantity.HeaderText = "Quantity"
TCQuantity.Width = 90
TCQuantity.ReadOnly = False
TSEquip.GridColumnStyles.Add(TCQuantity)
DataGridEquip.TableStyles.Add(TSEquip)

Nov 22 '05 #2
I'm no expert, but I think the mapping name for the grid needs to be same as
the table that the data is coming from. Try changing to...

TSEquip.MappingName = "Equipment_Details"
--
For real reply address, lose the cash
www.realuk.co.uk
"Angelina" <an*******@discussions.microsoft.com> wrote in message
news:1d****************************@phx.gbl...
Hi,

Im trying to format my datagrid via some code to make one
column readonly while the other can be edited.
I also tried to change the column header. The problem is
that the code does not seem to be taking effect.

Here is my code. Can anyone please offer me some help?

da = New SqlDataAdapter("SELECT Equipment_Desc, 0 as
Quantity FROM Equipment_Details", Cn)

ds = New DataSet("Equipment")
da.Fill(ds)

DataGridEquip.DataSource = ds.Tables(0)

Dim TSEquip As New DataGridTableStyle()
TSEquip.MappingName = "Equipment"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equipment_Desc"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 110
TCEquipName.ReadOnly = True
TSEquip.GridColumnStyles.Add(TCEquipName)

Dim TCQuantity As New DataGridTextBoxColumn()
TCQuantity.MappingName = "Quantity"
TCQuantity.HeaderText = "Quantity"
TCQuantity.Width = 90
TCQuantity.ReadOnly = False
TSEquip.GridColumnStyles.Add(TCQuantity)
DataGridEquip.TableStyles.Add(TSEquip)

Nov 22 '05 #3
Hi Rob,

Thx for your input. I just tried this but i still cant
see any of the formatting i am coding in the datagrid at
runtime!! :o(

Does anyone have any other suggestions?

-----Original Message-----
I'm no expert, but I think the mapping name for the grid needs to be same asthe table that the data is coming from. Try changing to...
TSEquip.MappingName = "Equipment_Details"
--
For real reply address, lose the cash
www.realuk.co.uk
"Angelina" <an*******@discussions.microsoft.com> wrote in messagenews:1d****************************@phx.gbl...
Hi,

Im trying to format my datagrid via some code to make one column readonly while the other can be edited.
I also tried to change the column header. The problem is that the code does not seem to be taking effect.

Here is my code. Can anyone please offer me some help?

da = New SqlDataAdapter("SELECT Equipment_Desc, 0 as
Quantity FROM Equipment_Details", Cn)

ds = New DataSet("Equipment")
da.Fill(ds)

DataGridEquip.DataSource = ds.Tables(0)

Dim TSEquip As New DataGridTableStyle()
TSEquip.MappingName = "Equipment"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equipment_Desc"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 110
TCEquipName.ReadOnly = True
TSEquip.GridColumnStyles.Add(TCEquipName)

Dim TCQuantity As New DataGridTextBoxColumn()
TCQuantity.MappingName = "Quantity"
TCQuantity.HeaderText = "Quantity"
TCQuantity.Width = 90
TCQuantity.ReadOnly = False
TSEquip.GridColumnStyles.Add(TCQuantity)
DataGridEquip.TableStyles.Add(TSEquip)

.

Nov 22 '05 #4
Hi Rob,

Thx for your input. I just tried this but i still cant
see any of the formatting i am coding in the datagrid at
runtime!! :o(

Does anyone have any other suggestions?

-----Original Message-----
I'm no expert, but I think the mapping name for the grid needs to be same asthe table that the data is coming from. Try changing to...
TSEquip.MappingName = "Equipment_Details"
--
For real reply address, lose the cash
www.realuk.co.uk
"Angelina" <an*******@discussions.microsoft.com> wrote in messagenews:1d****************************@phx.gbl...
Hi,

Im trying to format my datagrid via some code to make one column readonly while the other can be edited.
I also tried to change the column header. The problem is that the code does not seem to be taking effect.

Here is my code. Can anyone please offer me some help?

da = New SqlDataAdapter("SELECT Equipment_Desc, 0 as
Quantity FROM Equipment_Details", Cn)

ds = New DataSet("Equipment")
da.Fill(ds)

DataGridEquip.DataSource = ds.Tables(0)

Dim TSEquip As New DataGridTableStyle()
TSEquip.MappingName = "Equipment"

Dim TCEquipName As New DataGridTextBoxColumn()
TCEquipName.MappingName = "Equipment_Desc"
TCEquipName.HeaderText = "Equipment Name"
TCEquipName.Width = 110
TCEquipName.ReadOnly = True
TSEquip.GridColumnStyles.Add(TCEquipName)

Dim TCQuantity As New DataGridTextBoxColumn()
TCQuantity.MappingName = "Quantity"
TCQuantity.HeaderText = "Quantity"
TCQuantity.Width = 90
TCQuantity.ReadOnly = False
TSEquip.GridColumnStyles.Add(TCQuantity)
DataGridEquip.TableStyles.Add(TSEquip)

.

Nov 22 '05 #5
"Angelina" <an*******@discussions.microsoft.com> wrote in message
news:1d****************************@phx.gbl...
Here is my code. Can anyone please offer me some help? da.Fill(ds)
When you fill the dataset give it a tablename:

da.Fill(ds,"mytable")
TSEquip.MappingName = "Equipment"


Use the name here:
TsEquip.MappingName="mytable"

Tim
Investigating dotnet: http://www.itwriting.com/dotnet1.php
Nov 22 '05 #6
"Angelina" <an*******@discussions.microsoft.com> wrote in message
news:1d****************************@phx.gbl...
Here is my code. Can anyone please offer me some help? da.Fill(ds)
When you fill the dataset give it a tablename:

da.Fill(ds,"mytable")
TSEquip.MappingName = "Equipment"


Use the name here:
TsEquip.MappingName="mytable"

Tim
Investigating dotnet: http://www.itwriting.com/dotnet1.php
Nov 22 '05 #7

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

Similar topics

3
by: Angelina | last post by:
Hi, Im trying to format my datagrid via some code to make one column readonly while the other can be edited. I also tried to change the column header. The problem is that the code does not seem...
0
by: J. Muenchbourg | last post by:
I'm trying to use paging in a datagrid, but I can't get past the "cannot compute Count for a data source that does not implement ICollection" application error, as it does not point to a line in...
0
by: klynn | last post by:
I queried a series of fields from a database and passed into a datatable. Then bound this to a datagrid. I need to hide 2 of the colums. This doesnt seem to be working the standard way. (with...
1
by: tshad | last post by:
I can't seem to get insert into a DataGrid to work. I am using an example from the net and made changes to work on my computer. The grid comes up fine. The edit boxes in the footer are there. ...
9
by: A P | last post by:
Hi! I have created a sample datagrid that can update data on a database. Please help me solve the problem, I have attached both aspx and code behind (aspx.vb): ______________________ ...
3
by: tshad | last post by:
I am using VS 2003 and trying to build a standalone application. I have been writing all my asp.net work using DW and am just now trying to build a application that will read some of the tables I...
0
by: mh | last post by:
I have a datagrid on an aspx page that correctly shows my data using the following code: <form id="Form1" method="post" runat="server"> <asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT:...
1
by: suneel271 | last post by:
code working in internet explorer but not in mozilla and iam getting erroe like window.event has no properties and here is the code <%@ page language="java" contentType="text/html;...
3
by: kepskp | last post by:
i just write code for select option in combo box which i m select but when i press search button and then click on back button then there in no option selected. and that same code working in ie7 and...
5
daJunkCollector
by: daJunkCollector | last post by:
What I am doing here should be obvious. I have a datagrid that displays data properly. I want to create a linkbutton within each row of the datagrid that toggles a label control in the same row...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
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...

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.