473,396 Members | 2,090 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,396 software developers and data experts.

2.0: inaccessible control in DataList

RAM
Hi,
Please help again.
I have written DataList control with editing/deleting/adding rows - in .aspx
I have:
<asp:DataList ID="PositionsDataList" runat="server"

OnEditCommand="Positions_Edit"

OnUpdateCommand="Positions_Update"

OnCancelCommand="Positions_Cancel"

OnDeleteCommand="Positions_Delete"...

<FooterTemplate>

</tbody>

<tfoot>

<tr><td><asp:LinkButton ID="PositionsAdd" runat="server" Text="Add"
CommandName="Add" OnCommand="Positions_Add" /></td...

It works genarally fine. I have a problem with switching off Add button in
Positions_Add function (I want disable the control and go to edit mode of a
new row):
protected void Positions_Add(object sender, CommandEventArgs e)

{

PositionsDataList.EditItemIndex = PositionsDataList.Items.Count;

PositionsBind(connection, true);

((LinkButton)PositionsDataList.FindControl("Positi onsAdd")).Visible =
false;

}

There's an error in last line because FindControl returns null. I don't
understand why and I don't know how to write the code correctly.
Please help. Thanks.
/RAM/
Oct 9 '06 #1
3 1085
LinkButton button = (LinkButton)
PositionsDataList.Controls[PositionsDataList.Controls.Count -
1].FindControl("PositionsAdd")
--
Milosz Skalecki
MCP, MCAD
"RAM" wrote:
Hi,
Please help again.
I have written DataList control with editing/deleting/adding rows - in .aspx
I have:
<asp:DataList ID="PositionsDataList" runat="server"

OnEditCommand="Positions_Edit"

OnUpdateCommand="Positions_Update"

OnCancelCommand="Positions_Cancel"

OnDeleteCommand="Positions_Delete"...

<FooterTemplate>

</tbody>

<tfoot>

<tr><td><asp:LinkButton ID="PositionsAdd" runat="server" Text="Add"
CommandName="Add" OnCommand="Positions_Add" /></td...

It works genarally fine. I have a problem with switching off Add button in
Positions_Add function (I want disable the control and go to edit mode of a
new row):
protected void Positions_Add(object sender, CommandEventArgs e)

{

PositionsDataList.EditItemIndex = PositionsDataList.Items.Count;

PositionsBind(connection, true);

((LinkButton)PositionsDataList.FindControl("Positi onsAdd")).Visible =
false;

}

There's an error in last line because FindControl returns null. I don't
understand why and I don't know how to write the code correctly.
Please help. Thanks.
/RAM/
Oct 9 '06 #2
RAM
Thanks.

U¿ytkownik "Milosz Skalecki" <mi*****@REMOVEITwp.plnapisa³ w wiadomo¶ci
news:8F**********************************@microsof t.com...
LinkButton button = (LinkButton)
PositionsDataList.Controls[PositionsDataList.Controls.Count -
1].FindControl("PositionsAdd")
--
Milosz Skalecki
MCP, MCAD
"RAM" wrote:
>Hi,
Please help again.
I have written DataList control with editing/deleting/adding rows - in
.aspx
I have:
<asp:DataList ID="PositionsDataList" runat="server"

OnEditCommand="Positions_Edit"

OnUpdateCommand="Positions_Update"

OnCancelCommand="Positions_Cancel"

OnDeleteCommand="Positions_Delete"...

<FooterTemplate>

</tbody>

<tfoot>

<tr><td><asp:LinkButton ID="PositionsAdd" runat="server" Text="Add"
CommandName="Add" OnCommand="Positions_Add" /></td...

It works genarally fine. I have a problem with switching off Add button
in
Positions_Add function (I want disable the control and go to edit mode of
a
new row):
protected void Positions_Add(object sender, CommandEventArgs e)

{

PositionsDataList.EditItemIndex = PositionsDataList.Items.Count;

PositionsBind(connection, true);

((LinkButton)PositionsDataList.FindControl("Positi onsAdd")).Visible =
false;

}

There's an error in last line because FindControl returns null. I don't
understand why and I don't know how to write the code correctly.
Please help. Thanks.
/RAM/

Oct 10 '06 #3
Spoko :D
--
Milosz Skalecki
MCP, MCAD
"RAM" wrote:
Thanks.

U¿ytkownik "Milosz Skalecki" <mi*****@REMOVEITwp.plnapisa³ w wiadomo¶ci
news:8F**********************************@microsof t.com...
LinkButton button = (LinkButton)
PositionsDataList.Controls[PositionsDataList.Controls.Count -
1].FindControl("PositionsAdd")
--
Milosz Skalecki
MCP, MCAD
"RAM" wrote:
Hi,
Please help again.
I have written DataList control with editing/deleting/adding rows - in
.aspx
I have:
<asp:DataList ID="PositionsDataList" runat="server"

OnEditCommand="Positions_Edit"

OnUpdateCommand="Positions_Update"

OnCancelCommand="Positions_Cancel"

OnDeleteCommand="Positions_Delete"...

<FooterTemplate>

</tbody>

<tfoot>

<tr><td><asp:LinkButton ID="PositionsAdd" runat="server" Text="Add"
CommandName="Add" OnCommand="Positions_Add" /></td...

It works genarally fine. I have a problem with switching off Add button
in
Positions_Add function (I want disable the control and go to edit mode of
a
new row):
protected void Positions_Add(object sender, CommandEventArgs e)

{

PositionsDataList.EditItemIndex = PositionsDataList.Items.Count;

PositionsBind(connection, true);

((LinkButton)PositionsDataList.FindControl("Positi onsAdd")).Visible =
false;

}

There's an error in last line because FindControl returns null. I don't
understand why and I don't know how to write the code correctly.
Please help. Thanks.
/RAM/


Oct 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
1
by: bill yeager | last post by:
I have a datagrid control within a datalist control. When I try and do a "Find" on the control, the object comes back with nothing and then my pgm crashes. I am 100% sure that my datagird inside...
6
by: Davids | last post by:
having a 100% working aspx page I wanted to create a user control from a small DataList section (which has an ID="DataList1") of the page, so I created an ascx file with the DataList and Register...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
0
by: Rick Wez | last post by:
I feel like I'm going to pull out my hair (there's not much left); I've read almost every online post trying to figure this out. So I started over with something VERY simple and it still doesn't...
4
by: Sam Martin | last post by:
Hi, I have got a User Control that contains for the sake of argument, a single DataList control. eg. <asp:DataList id="DataListMain" runat="server" RepeatDirection="Horizontal"...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
6
by: Victor | last post by:
Hi. all I have a customize web control. I have three simple properties and customized render class. then I add this control into my datalist like <asp:DataList ID="datalist" runat="server"...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.