473,385 Members | 1,821 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.

How to FindControl in DataGrid ItemCommand

Hello Every One:
Can some one give me iDeas How do I disable the DataGrid controls in ItemCommand using VB.
For Example I have dropdownlist bound in my DataGrid. Now I want to Disable this control in Datagrid_ItemCommand.
I tried like this
'''''''''''''''''''''''''''''
Expand|Select|Wrap|Line Numbers
  1. Select Case e.CommandName
  2.  
  3.             Case "Edit" '//Edit Case
  4.  
  5.  
  6.  
  7.                 dgIncentive.EditItemIndex = e.Item.ItemIndex
  8.  
  9.                 Dim ddlOwner, ddlUser As DropDownList
  10.  
  11.                                          '' Disable ddlOwnerNett And ddlUserNet ''
  12.  
  13.                 Dim str_Sql As String = "SELECT manager FROM Inc_Agency_Header " & _
  14.  
  15.                                         " WHERE Incentive_ID = '" & ddlIncentive.SelectedValue & "'"
  16.  
  17.                 Dim dsManager As DataSet = DataProvider.GetDataInterface.ExecuteQuery(str_Sql)
  18.  
  19.                 If dsManager.Tables(0).Rows.Count > 0 Then
  20.  
  21.                     If dsManager.Tables(0).Rows(0).Item("Manager") = 0 Then
  22.  
  23.                      ddlUser = CType(e.Item.Cells(15).FindControl("edit_ddlUserNett"), DropDownList)
  24.  
  25.                         ddlUser.Enabled = True
  26.  
  27.                     End If
  28.  
  29.                 End If
  30.  
'''''''''''''''''''''''''''''
But Unfortunately

CType(e.Item.Cells(15).FindControl("edit_ddlUserNe tt"), DropDownList)

returning "Nothing".

Thanx

Regards
Nov 11 '10 #1
1 3221
Hi Zohaib

If you use
CType(e.Item.FindControl("edit_ddlUserNe tt"), DropDownList)

instead of

CType(e.Item.Cells(15).FindControl("edit_ddlUserNe tt"), DropDownList)

it will work because the dropdownlist control dosenot belong to cell it only belongs to row, so need to refrence Cells(15)
Nov 12 '10 #2

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

Similar topics

0
by: Jyoti | last post by:
Hi, I am developing asp.net application. i am generating datagrid button column dynamically. and on click of a button click resp. command doesn't get fired. why is it so? if i provide at design...
1
by: Mike | last post by:
I have a DataGrid that I am binding to a DataSet. I am adding a button to the DataGrid for users to retrieve additional information about that record. The problem I have is that the ItemCommand...
2
by: Nick Gilbert | last post by:
We have a Datagrid which contains a template column with a button in it, as well as an actual button column. If either of the buttons are clicked, the ItemCommand event does not fire. If...
0
by: Mark Kelly | last post by:
(originally posted on framework.aspnet.datagridcontrol) Hi, I don't seem to be able to get a imagebutton (within a template column) to fire an itemcommand event when clicked. Looking through this...
2
by: Syed Sami R. Shah | last post by:
hi all, i am having problem with using itemcommand of datagrid by way of asp:image button. i have put an image button in a datagrid item template and have set CommandName="DeleteRecord" and have...
2
by: Deepesh | last post by:
Good day, I have a specific case of the DataGrid in my solution which is causing the ItemCommand Event Not Firing. So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX file...
3
by: danc | last post by:
I have a datagrid with a checkbox and dropdown list in each row. Both set AutoPostBack to true and ItemCommand and OnSelectedIndexChanged events for these controls works fine when DataGrid is not...
1
by: Adam Knight | last post by:
Hi all, I have a datagrid like so: <asp:datagrid id="dgContractors" OnItemCommand="dgContractor_ItemCommand" Runat="server" Width="920"> Shortened for brevity..
1
by: orangedesk | last post by:
Please let me know what all options can I try to make the itemcommand get called when a image button gets clicked? I tried some of the options like checking the autopost back before binding the...
0
by: jigsawcube1 | last post by:
I am trying to accept two input strings and concatinate and display the result in a datagrid. Following is the HTML and code. ItemCommand does not get fired what is that I am missing? <body...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.