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

Need to set datagrid column to readonly based on values

2
I have a datagrid that is editable by the user. Some of the columns are readonly and others can be edited. I have one column that I need to be able to make readonly based on the values of other columns, otherwise it remains editable.

I want to set this property in the itemdatabound event as the datagrid is loaded. Below is my ItemDataBound routine to show what I'm trying to do. Everything else works; I just need to be able to conditionally set a cell to be ReadOnly.

Private Sub grdShipItems_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdShipItems.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.AlternatingItem, ListItemType.Item
If rdoActionType.SelectedValue.ToString = "Serial" Then
e.Item.Cells(0).Controls(0).Visible = False 'Hide the Edit btn
End If
If rdoActionType.SelectedValue.ToString = "Detail" Then
Dim strSQL, strConn As String
strConn = Session("ConnectString").ToString
strSQL = "SELECT Count(*) FROM tblSerialNums WHERE LineItemID = "
strSQL &= e.Item.Cells(5).Text
If DataHandler.ExecuteScalar(strSQL, strConn) > 0 Then
NEED TO SET READONLY PROPERTY OF CELL HERE
End If
End If
End Select
End Sub


TIA,
Mike
Oct 27 '06 #1
1 1516
Mike G
2
Does anybody know how to do this? TIA!!
Nov 1 '06 #2

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

Similar topics

6
by: Shivang | last post by:
Hello Everybody, I am using Datagrid in VB.net. I don't want the auto generation of rows in the datagrid (last row shouldnt be the new row with empty values)..in addition to this the datagrid...
0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
0
by: Rudolph Araujo | last post by:
Hi, I needed to build a data grid in which the first column has hyperlinks rather than simple text. I found the following code on this newsgroup and it works fine except for one problem. When I...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
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...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
0
by: dsmigelski | last post by:
I have a datagrid that I am populating, and on my tab and I have a select/Deselect all checkboxes. The only column in my grid that is readable is the first column and it is a bit field displaying...
3
by: Lars Netzel | last post by:
(applies to Windows Form .NET 2003) I'm filling a datagrid from a Datatable and applying a DataGridStyle. The Source Fields are "Name", "Value", "Locked" and the Style's Columns are "Name",...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.