I have an array list that I want to display to the browser. I need very
precise control of the repeater, so I have function for the OnItemDataBound
event for the repater, then in that function I have my code to alter the
displayed data. for instance, I need to display a button on the client side
with client side script. I cannot accomplish this using the Button web
control, so instead I use a label and in the text of the label I set it to
((Label)e.Item.FindControl("DeleteButton")).Text=" <button
onclick='DeleteEntry(" +
((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() +
")'>Delete</button>";
Here is my code
private void Page_Load(object sender, System.EventArgs e)
{
ProjectProcess businessLogic = new ProjectProcess();
double SIDID = double.Parse(Request.Params["id"]);
ArrayList securityEntries;
securityEntries = businessLogic.listSecurityEntries(SIDID);
Repeater1.DataSource = securityEntries;
Repeater1.DataBind();
}
public void repeater1ItemDataBound(Object source,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
((HyperLink)e.Item.FindControl("lblUser")).Text =
(string)DataBinder.Eval(e.Item.DataItem,"UserName" );
((HyperLink)e.Item.FindControl("lblUser")).Navigat eUrl =
"Security.aspx?user=" +
((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString();
((Label)e.Item.FindControl("DeleteButton")).Text=" <button
onclick='DeleteEntry(" +
((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() +
")'>Delete</button>";
}
}
The client side code for the DeleteEntry function is as follows:
function DeleteMe(userid)
{
if(confirm("Are you sure you want to delete the record?"))
{
window.location="Security.aspx?command=delete&user =" + userid;
}
return;
}
Anywayz, I thought to myself, if I just create on label, and in the label,
change the text in code to display what I want instead of using a repeater
control all together. This would be much like using the old ASP model and
using the reponse.write method where I wanted to display the data. the only
difference here is that I cannot use the reponse.write function here because
I would be writing to the end of my reponse html code returned to the
client. I know there is a performance hit with calling the OnItemDataBound
event. Would the method I just described be less of a performance hit, or is
there another way of looking at this? Thanks 3 3007
you can use the button control and use reflection to get the instance and
add the onclick attribute to it then. Something like
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType ==
ListItemType.Item )
{
Button ib = (Button)e.Item.FindControl("DeleteButton");
ib.Attributes.Add("onclick","DeleteEntry(" +
((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")";
}
MattC
"Shawn H. Mesiatowsky" <smesiatowsky@_no_spam_perfectfit-ind.com> wrote in
message news:eP*************@tk2msftngp13.phx.gbl... I have an array list that I want to display to the browser. I need very precise control of the repeater, so I have function for the OnItemDataBound event for the repater, then in that function I have my code to alter the displayed data. for instance, I need to display a button on the client side with client side script. I cannot accomplish this using the Button web control, so instead I use a label and in the text of the label I set it to ((Label)e.Item.FindControl("DeleteButton")).Text=" <button onclick='DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")'>Delete</button>";
Here is my code
private void Page_Load(object sender, System.EventArgs e) { ProjectProcess businessLogic = new ProjectProcess(); double SIDID = double.Parse(Request.Params["id"]); ArrayList securityEntries;
securityEntries = businessLogic.listSecurityEntries(SIDID); Repeater1.DataSource = securityEntries; Repeater1.DataBind(); }
public void repeater1ItemDataBound(Object source, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ((HyperLink)e.Item.FindControl("lblUser")).Text = (string)DataBinder.Eval(e.Item.DataItem,"UserName" ); ((HyperLink)e.Item.FindControl("lblUser")).Navigat eUrl = "Security.aspx?user=" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString(); ((Label)e.Item.FindControl("DeleteButton")).Text=" <button onclick='DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")'>Delete</button>";
}
} The client side code for the DeleteEntry function is as follows:
function DeleteMe(userid) { if(confirm("Are you sure you want to delete the record?")) { window.location="Security.aspx?command=delete&user =" + userid; } return; }
Anywayz, I thought to myself, if I just create on label, and in the label, change the text in code to display what I want instead of using a repeater control all together. This would be much like using the old ASP model and using the reponse.write method where I wanted to display the data. the only difference here is that I cannot use the reponse.write function here because I would be writing to the end of my reponse html code returned to the client. I know there is a performance hit with calling the OnItemDataBound event. Would the method I just described be less of a performance hit, or is there another way of looking at this? Thanks
Tried that, but the output from the button control makes it type=submit so a
clientside script to use window.navigate('someurl.htm'); will not work
"MattC" <m@m.com> wrote in message
news:u%***************@TK2MSFTNGP15.phx.gbl... you can use the button control and use reflection to get the instance and add the onclick attribute to it then. Something like
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item ) { Button ib = (Button)e.Item.FindControl("DeleteButton"); ib.Attributes.Add("onclick","DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")"; }
MattC
"Shawn H. Mesiatowsky" <smesiatowsky@_no_spam_perfectfit-ind.com> wrote in message news:eP*************@tk2msftngp13.phx.gbl...I have an array list that I want to display to the browser. I need very precise control of the repeater, so I have function for the OnItemDataBound event for the repater, then in that function I have my code to alter the displayed data. for instance, I need to display a button on the client side with client side script. I cannot accomplish this using the Button web control, so instead I use a label and in the text of the label I set it to ((Label)e.Item.FindControl("DeleteButton")).Text=" <button onclick='DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")'>Delete</button>";
Here is my code
private void Page_Load(object sender, System.EventArgs e) { ProjectProcess businessLogic = new ProjectProcess(); double SIDID = double.Parse(Request.Params["id"]); ArrayList securityEntries;
securityEntries = businessLogic.listSecurityEntries(SIDID); Repeater1.DataSource = securityEntries; Repeater1.DataBind(); }
public void repeater1ItemDataBound(Object source, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ((HyperLink)e.Item.FindControl("lblUser")).Text = (string)DataBinder.Eval(e.Item.DataItem,"UserName" ); ((HyperLink)e.Item.FindControl("lblUser")).Navigat eUrl = "Security.aspx?user=" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString(); ((Label)e.Item.FindControl("DeleteButton")).Text=" <button onclick='DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")'>Delete</button>";
}
} The client side code for the DeleteEntry function is as follows:
function DeleteMe(userid) { if(confirm("Are you sure you want to delete the record?")) { window.location="Security.aspx?command=delete&user =" + userid; } return; }
Anywayz, I thought to myself, if I just create on label, and in the label, change the text in code to display what I want instead of using a repeater control all together. This would be much like using the old ASP model and using the reponse.write method where I wanted to display the data. the only difference here is that I cannot use the reponse.write function here because I would be writing to the end of my reponse html code returned to the client. I know there is a performance hit with calling the OnItemDataBound event. Would the method I just described be less of a performance hit, or is there another way of looking at this? Thanks
You could use an Image button, they look nicer too!
MattC
"Shawn H. Mesiatowsky" <smesiatowsky@_no_spam_perfectfit-ind.com> wrote in
message news:e2**************@TK2MSFTNGP10.phx.gbl... Tried that, but the output from the button control makes it type=submit so a clientside script to use window.navigate('someurl.htm'); will not work
"MattC" <m@m.com> wrote in message news:u%***************@TK2MSFTNGP15.phx.gbl... you can use the button control and use reflection to get the instance and add the onclick attribute to it then. Something like
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item ) { Button ib = (Button)e.Item.FindControl("DeleteButton"); ib.Attributes.Add("onclick","DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")"; }
MattC
"Shawn H. Mesiatowsky" <smesiatowsky@_no_spam_perfectfit-ind.com> wrote in message news:eP*************@tk2msftngp13.phx.gbl...I have an array list that I want to display to the browser. I need very precise control of the repeater, so I have function for the OnItemDataBound event for the repater, then in that function I have my code to alter the displayed data. for instance, I need to display a button on the client side with client side script. I cannot accomplish this using the Button web control, so instead I use a label and in the text of the label I set it to ((Label)e.Item.FindControl("DeleteButton")).Text=" <button onclick='DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")'>Delete</button>";
Here is my code
private void Page_Load(object sender, System.EventArgs e) { ProjectProcess businessLogic = new ProjectProcess(); double SIDID = double.Parse(Request.Params["id"]); ArrayList securityEntries;
securityEntries = businessLogic.listSecurityEntries(SIDID); Repeater1.DataSource = securityEntries; Repeater1.DataBind(); }
public void repeater1ItemDataBound(Object source, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ((HyperLink)e.Item.FindControl("lblUser")).Text = (string)DataBinder.Eval(e.Item.DataItem,"UserName" ); ((HyperLink)e.Item.FindControl("lblUser")).Navigat eUrl = "Security.aspx?user=" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString(); ((Label)e.Item.FindControl("DeleteButton")).Text=" <button onclick='DeleteEntry(" + ((int)DataBinder.Eval(e.Item.DataItem,"UserID")).T oString() + ")'>Delete</button>";
}
} The client side code for the DeleteEntry function is as follows:
function DeleteMe(userid) { if(confirm("Are you sure you want to delete the record?")) { window.location="Security.aspx?command=delete&user =" + userid; } return; }
Anywayz, I thought to myself, if I just create on label, and in the label, change the text in code to display what I want instead of using a repeater control all together. This would be much like using the old ASP model and using the reponse.write method where I wanted to display the data. the only difference here is that I cannot use the reponse.write function here because I would be writing to the end of my reponse html code returned to the client. I know there is a performance hit with calling the OnItemDataBound event. Would the method I just described be less of a performance hit, or is there another way of looking at this? Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ckerns |
last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0).
If value is null or non-numeric I want to assign the value of "0".
rowString = "L411" //conrol name
if (isNaN(eval...
|
by: Mark Broadbent |
last post by:
In VB6 (using visual studio) it was possible to create a control array at
design time by simply adding the control (e.g. textbox) and renaming it to
what would become the first element
e.g.
...
|
by: RSB |
last post by:
Hi Every one,
i am trying to create a UserControl and i am passing a Array of strings to
it. Now based on the Array elements i am creating the LinkButtons
Dynamically. I am also passing a Event to...
|
by: serge calderara |
last post by:
Dear all,
I try to understand how this Repeater and DatalIst works but sounds really
confusing.
Why if I do the following code I have a completly balnk page, not data gets
display and even no...
|
by: Tom |
last post by:
I am having a really annoying issue with serialization and a .NET User
Control I am writing. For example, let's say I have a couple of classes in
my control - first class is like:
Public Class...
|
by: Mike |
last post by:
Hi,
I am strugling with a simple problem which I can't seem to resolve.
I have an asp.net page which contains a server-control (flytreeview,
which is a kind
of a tree to be exact).
The tree is...
|
by: XaviGR |
last post by:
I'm working on a user defined control, with a simple label.
My control has this function:
Sub AddRow(ByVal Texto As String)
When I execute AddRow("Sample") I want that my control adds a...
|
by: Rick |
last post by:
Hello,
I built a composite web control that has a textbox and a date
control.
added my custom control on a webform where there are other standard
controls.
Each control on the form has a...
|
by: markr1000 |
last post by:
I must have looked searched in 500+ places that showed up in Google
searchs, but not one has an example of what I want to do.
I have a Listbox on a User Control because I want to control the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |