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

GridView Primary Key

Hello,

I have a data table which is already created with all columns and
data.

I need to define LevelName column as its Primary Key so I can use Find
in it.

I tried the following but it is giving me errors:

dtLevels.PrimaryKey = dtLevels.Columns.Item("LevelName")

What am I doing wrong?

Thanks,

Miguel

Mar 8 '07 #1
2 4017
"shapper" <md*****@gmail.comwrote in message
news:11**********************@c51g2000cwc.googlegr oups.com...
What am I doing wrong?
The PrimaryKey property of a DataTable is an *array* of columns, even if
there is only one column in the primary key:
http://msdn2.microsoft.com/en-us/lib...rimarykey.aspx
Mar 8 '07 #2
dtLevels.PrimaryKey = New DataColumn(){
dtLevels.Columns.Item("LevelName") }

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"shapper" <md*****@gmail.comwrote in message
news:11**********************@c51g2000cwc.googlegr oups.com...
Hello,

I have a data table which is already created with all columns and
data.

I need to define LevelName column as its Primary Key so I can use Find
in it.

I tried the following but it is giving me errors:

dtLevels.PrimaryKey = dtLevels.Columns.Item("LevelName")

What am I doing wrong?

Thanks,

Miguel
Mar 8 '07 #3

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

Similar topics

0
by: Stephen | last post by:
My primary GridView is firing an OnDataBound after Selecting a row (which triggers SelectedIndexChanged). This only happens in the following scenario: - User enters a textbox search value and...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
0
by: R.A.M. | last post by:
Hello, Could you help me please to define GridView associated to DropDownList. My DropDownList "Publishers" should show publishers' names from SQL Server table Publishers. My GridView...
1
by: Raja | last post by:
Hi Everybody Just playing with ObjectDataSource and noticed the following. I have a Gridview which binds to a ObjectDataSource. ObjectDataSource gets data from a typed dataset created with VWD. In...
1
by: R.A.M. | last post by:
Hello, Could you help me please to define GridView associated to DropDownList... My DropDownList "Publishers" should show publishers' names from SQL Server table Publishers. My GridView...
2
by: Richard Carpenter | last post by:
I have a four-page tabcontrol with a gridview on each page. I have the primary key column of each gridview set to hidden (visible = false), but it still shows up on all but the first page. Anyone...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
3
by: pvong | last post by:
VB.NET How do you change a gridview from Update mode to normal mode? I'm usually dealing for Formviews and there is a ChangeMode option but I don't see one for Gridviews.
4
by: Jonathan Wood | last post by:
Greetings, I have a GridView control. For a couple of reasons, I ended up with a TemplateField to contain my Edit and Delete links, something like this: <asp:TemplateField ShowHeader="False">...
2
by: William LaMartin | last post by:
On webform, I am populating a GridView from a SQLDatasource based on a MySQL table named PIB. There is no vb code involved. Everything is done in the source for the aspx page, provided below. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
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...

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.