itemtemplates all contain Label controls displaying a number), However, when someone clicks the Edit button on a Grid View Row, if they were not the person who originally added the record to the database, they cannot alter the value in column 1 (textbox), but can still edit the values in columns 2 and 3. However I want to suggest another method which may be useful for you in some other cases.I am looking for the right place to put the code that disables the textbox in column 1. Edit; but this doesn't work as it is read only. The problem is "reaching the controls inside the Edit Item Template of a data presenter (e.g. I have faced with the same problem with a Datalist control which I called "dl_albums" and I tried to use the edit Command function as follows but unfortunately it DOES NOT WORK: protected void dl_albums_Edit Command(object source, Data List Command Event Args e) cblist is a checkboxlist control that is defined in the Edit Item Template of the datalist .
As I hit a button to go from a view to another, I want to disable all the controls on the previous view so the end user can't go back to the previous view using his backspace key or Back button on his browser.
I can achieve my objective by going through each control and setting is Enabled = false, but it would be really great if there is a way to put the controls into a group and simply disable the group versus 5-10 controls.
Alok Hi aloksinha83, Please see this post: Qin Dian Tang Microsoft Online Community Support Please remember to mark the replies as answers if they help and unmark them if they provide no help....
CREATE TABLE [dbo].[Brand]( [ID] [bigint] NOT NULL, [Name] [varchar](max) NOT NULL, CONSTRAINT [PK_Brand] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] CREATE TABLE [dbo].[Product]( [ID] [bigint] NOT NULL, [Name] [varchar](max) NULL, [Description] [varchar](max) NULL, [Brand ID] [bigint] NULL, CONSTRAINT [PK_Product_2] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] INSERT INTO Brand Values(1,'Kohinoor') INSERT INTO Brand Values(2,'Proctor & Gamble') INSERT INTO Brand Values(3,'Telenor') INSERT INTO Brand Values(4,'Unilever') INSERT INTO PRODUCT VALUES(1,'Lux Beauty Soap','Product of Unilever',4) INSERT INTO PRODUCT VALUES(2,'Tibbet Pomed','Winter Product',1) INSERT INTO PRODUCT VALUES(3,'Data SIM','Subscriber Identity Module',3) INSERT INTO PRODUCT VALUES(4,'Nippon','Color Television',1) Protected Sub Page_Load(sender As Object, e As System. Load If Not Is Post Back Then Bind Grid View() End If End Sub Private Sub Bind Grid View() Dim dt As Data Table Dim SQL As [String] = "SELECT P.
To String() ' You also control the show hide enable disable here. Enabled = False End If End If End Sub -1 Then Dim cbo Brand As Drop Down List = Direct Cast(Grid View1. I tried the Row Updating event, but could only access the Label controls in the itemtemplates (as at this stage, the row hasn't actually entered Edit mode). Very simplified markup: Sort of code I am trying: Grid View Row gvr = (Grid View Row)Grid View. Row Index etc..)if (conditional args to find if person owns record.....) this of course isn't working - it is not finding the textbox becuase I cannot figure out when the edititemtemplate controls become available. In this code cblist is always NULL because at the moment this function is reached the Datalist is still in normal mode (not in the edit mode) eventhough this function is called when the user presses the edit button. Item Index gives us the index of the row that is just bound with data.Rows[int]; (or, depending on where it lives, setting the row by event Args i.e. Within this function you can reach any control defined in the Item Template of the Datalist but not the controls that are in the Edit Item Template of the Datalist. When this conditional statement is true then that means "the Data Item that is being edited is currently bound with data." While this is true then we can reach the control inside the Edit Item Template of that Data Item. :- On Disabling Controls Present inside a Gridview control Hi All, We have A requirement Where we have disable controls inside a grid.What one has to do in order to reach the controls in edit Item Template is using the Item Data Bound function (this function is specific to Data List Control, if it is a Gridview you can use the row Data Bound function). Edit Item Index is the index of the row being edited. My code for my specific application is as follows: protected void dl_albums_Item Data Bound(object sender, Data List Item Event Args e) Tom, may be you already solved this but I wanted other people that face this same problem to take as reference. These controls can be textbox, Drop Downlist (in Template Field), Comand Field present inside the grid.This function is called everytime a data Item of the datalist is bound with some data (therefore launches for every single data Item of the Datalist). We have to call a generic method for doing the same .(since it can be done for multiple grid.) PFB the code snippet we use. The bolded part of the code is used to loop inside a grid view.(Not Working.)Is this ideal way to deal with the requirement. public void Disable Me(Page p1, st...disable textbox control and dropdownlist control when selecting one of the radiobuttons I want to disable the textbox control (also change its background colour) and dropdownlist control when I select one of the radiobuttons.But there is an alternative, we can reference the above controls within Grid View edit mode in Pre Render method which is best i think. Open() Using da As New Sql Data Adapter(comm) dt = New Data Table("tbl") da. Open() Using da As New Sql Data Adapter(comm) dt = New Data Table("tbl") da.