C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Accessing Controls from a datagrid


Posted Date: 20 May 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Rakesh Chander SharmaMember Level: Silver    
Rating: 1 out of 5Points: 7



This is the first article i am submitting on this site. There are various issues that you may face when you work with live projects . In Asp.Net you have to customize controls and all this you dont get in books. I would like to tell you how to access various controls that you place in a datagrid.Suppose you have placed a checkbox in a datagrid and you want to perform some action for all those rows which have been checked. here is the way you go about checking all those checkboxes.


For Each dgi In DTG.Items
cb = CType(dgi.Cells(13).Controls(1), CheckBox)
If cb.Checked Then
//task to be done here
End If
Next


Here in this code DTG represents the data grid and the cells represents the no. of colum on which the control has been placed,by default first row is represented as 0 . The control specifies the no. of that control.

In a similar way you can check a grid for other controls and access them accordingly.



Responses

Author: Jon Holmes    09 Jun 2004Member Level: Bronze   Points : 0
This works well. But to make it clearer for inexperienced .net developers you should include the declarations:

Dim dgi As DataGridItem
Dim cb As CheckBox

Apart from that it's great.


Author: Balasubramanian    25 Jun 2004Member Level: Bronze   Points : 0
Hi Rakesh sharma,
You code is used get control from server side, my sample used to get server side control from client side.

for(IntCount=0;IntCount{
if(MyForm.elements[IntCount].type=="text")
StrObjectValue=MyForm.elements[IntCount].value
}



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Differences Between XMLDOM and .NET XML
Previous Resource: How to set the Top and left property of a web control dynamically?
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use