Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2015, 07:06 AM
dpk dpk is offline
Registered User
 
Join Date: Jan 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to get EditItemTemplate Control in Rowcommand Event

hi frnds,

i need to get the control that exist inside the <EditItemTemplate> from _RowCommand..
but it is not there..
what is wrong..

if I find for hdnID control i am getting it but if I loog for hdnIDEdit then it gives me null.

pls see The line in Bold always giving me NULL.


<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:TextBox ID="txtTitle" runat="server" BackColor="Transparent" ReadOnly="true" BorderStyle="None" Text='<%# Eval("title") %>' />
<asp:HiddenField ID="hdnID" runat="server" Value='<%# Eval("ID") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTitleEdit" runat="server" Text='<%# Eval("title") %>' />
<asp:HiddenField ID="hdnIDEdit" runat="server" Value='<%# Eval("ID") %>' />
</EditItemTemplate>
</asp:TemplateField>

====================================

protected void gvListData_RowCommand(object sender, GridViewCommandEventArgs e)
{
Int32 rowIndex = ((GridViewRow)(((LinkButton)e.CommandSource).Namin gContainer)).RowIndex;
if (e.CommandName == "EditMe")
{
gvListData.EditIndex = rowIndex;
SPList oListSelected = getList("/sites/PerfettiSC/Lists/" + ddlListIds.Text);
BindList(oListSelected);
((Panel)(gvListData.Rows[rowIndex].FindControl("pnlUpdate"))).Visible = true;
((Panel)(gvListData.Rows[rowIndex].FindControl("pnlEdit"))).Visible = false;
}

if (e.CommandName == "UpdateMe")
{
gvListData.EditIndex = rowIndex;
HiddenField hdn = (HiddenField)gvListData.Rows[rowIndex].FindControl("hdnIDEdit")
}
}
 
Old February 16th, 2015, 01:32 AM
Registered User
 
Join Date: Feb 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please note: If you are under an NDA related to ASP.NET 2.0, please don't post any information here that will violate your NDA. This is a public forum, not associated with the Microsoft beta program.



__________________________________________________ ___________

solitairechamp online patience klondike cards games

Last edited by asalspammer; January 2nd, 2016 at 01:24 AM..
 
Old February 16th, 2015, 01:34 PM
Friend of Wrox
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

I for one would not reinvent the wheel unless absolutely needed to with event. The are already events defined for updating and rowbindding that you could used to do the 2 function that you are trying to do in the rowcommand event
 
Old February 16th, 2015, 01:47 PM
Friend of Wrox
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

Also FindControl only does a search of immediate child controls and not of any grandchild controls. You need to implement a search that find a control no matter where in the control structure it is located. Check out this post Checkbox in GridView





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to get blur event working - chap 16 pitters BOOK: Beginning ASP.NET 4.5 : in C# and VB 8 January 11th, 2014 04:05 PM
Can't find control in GridView RowCommand rsearing ASP.NET 2.0 Professional 8 September 10th, 2011 07:10 PM
Javascript functions from Gridview RowCommand Event Phil Critchley ASP.NET 4 General Discussion 21 May 3rd, 2011 10:55 PM
Click event not firing for Dynamic button control when it has validation control Gayathri79 ASP.NET 3.5 Basics 5 August 20th, 2010 06:58 PM
Unable to fire a click event rfinks ASP.NET 1.0 and 1.1 Basics 2 September 1st, 2006 10:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.