p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/asp-net-2-0-basics-136/)
-   -   Unable to get EditItemTemplate Control in Rowcommand Event (http://p2p.wrox.com/asp-net-2-0-basics/94021-unable-get-edititemtemplate-control-rowcommand-event.html)

dpk January 22nd, 2015 07:06 AM

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")
}
}

asalspammer February 16th, 2015 01:32 AM

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

mmorgan30 February 16th, 2015 01:34 PM

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

mmorgan30 February 16th, 2015 01:47 PM

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 http://p2p.wrox.com/asp-net-4-genera...-gridview.html


All times are GMT -4. The time now is 07:25 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.