Click here to Skip to main content
       

ASP.NET

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionFindControl not working in Gridview ItemTemplate of ButtonmemberMember 974870717 Jan '13 - 19:42 
The findcontrol event is not getting the control e.g. "btnSubmit" placed inside a gridview itemtemplate tag.
please help with code in VB.NET
AnswerRe: FindControl not working in Gridview ItemTemplate of Buttongroupchester_it2118 Jan '13 - 6:16 
<ItemTemplate>
 <asp:CheckBox ID="chkItemSelect" runat="server" />
 <asp:Label ID="lblname" Text='<%#Bind("name")%>' runat="server" />              
<asp:Button ID="btnFindx" runat="server" CommandName="Findx" Text="Do Some thing" CommandArgument='<%#Eval("ID")%>'></asp:Button>
                                        </ItemTemplate>
 
So, in event OnRowCommand(Code Behind) :
 
Protected Sub GridView_RowCommand(sender As [Object], e As GridViewCommandEventArgs)
	Select Case e.CommandName
		Case "Findx"
			MethodFindControlValue()
			Exit Select
	End Select
End Sub
 
..in MethodFindControlValue() :
Private Sub MethodFindControlValue()
	For Each row As GridViewRow In ApprovalGrid.Rows
		Dim chkItemSelect As CheckBox = CType(row.FindControl("chkItemSelect"), CheckBox)
		Dim chkItemSelect As Label = CType(row.FindControl("lblname"), CheckBox)
 
		Dim id As String = Convert.ToString(NameGridView.DataKeys(row.RowIndex).Value.ToString())
	Next
End Sub
 
 

hope this help you............Big Grin | :-D
QuestionRe: FindControl not working in Gridview ItemTemplate of ButtonmemberNandakishorerao18 Jan '13 - 21:48 
paste the code what you have done till now?..so that we can help you in correcting the errors.
AnswerRe: FindControl not working in Gridview ItemTemplate of ButtonmemberKanwal Daud Gill21 Jan '13 - 20:23 
Thanks for the help dear!
but my case was solved as I used the LINK BUTTON instead of button in the itemtemplate tag of Gridview
GeneralRe: FindControl not working in Gridview ItemTemplate of ButtonmemberNandakishorerao21 Jan '13 - 20:49 
ok...sure...enjoy coding...all the best..

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid