Hi All
This is my first query in this site. firstly i like to appreciate all the contributors of this site and solutions.
I am having an issue while using DataList dynamically. I am able to bind dynamic itemtemplate and dynamic linkbutton in that itemtemplate and displaying data and linkbuttons successfully. but i am not able to fire click event of the rendered linkbuttons even i registered the click event correctly.
also for the safe side i also registered ItemCommand event of DataList.
i have to achieve this task dynamically. there is no aspx or ascx code to be used i am using C# class file.
please revert back if you need any more information to solve my issue.
Your help is highly appricated.
Thanks
Raj
7 7748 Frinavale 9,735
Recognized Expert Moderator Expert
Welcome to the ASP.NET forum Raj :)
I'm glad you were finally able to post your question.
First of all, did you implement a method to handle the DataList's ItemCommand Event?
If not, try it, does this work?
If it doesn't work then it's likely that you have to bubble up the event in any custom item templates you have implemented.
Thank you, and because of you i am able to use BYTES. Yes i am handling ItemCommand event.
Another thing i have to mention is..my appliation is implementation of custom webpart. so there are 2 classes that i am using in my program. 1 is class which implements webpart class and another class is which implements Itemplate for creating custom template.
i am rendering all controls in CreateChildCont rol( ) method. also i avoided postback problem that will cause problem for dynamic link buttons.
i am placing my logic that i implemented -
public class RelatedOrganizations : System.Web.UI.WebControls.WebParts.WebPart
-
{
-
//variables
-
DataList dataListTop;
-
DataList dataListBottom;
-
-
//methods
-
protected override void CreateChildControls()
-
{
-
if (!Page.IsPostBack)
-
{
-
-
//adding properties to my datalist
-
dataListBottom = new DataList();
-
dataListBottom.ItemCommand += new DataListCommandEventHandler(dataListBottom_ItemCommand);
-
dataListBottom.SelectedIndexChanged += new EventHandler(dataListBottom_SelectedIndexChanged);
-
TemplateField tfBottom = new TemplateField();
-
tfBottom.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, strSalesPositionDescriptionColumn);
-
tfBottom.ItemTemplate = new GridViewTemplate(DataControlRowType.DataRow, strSalesPositionIdColumn);
-
dataListBottom.ItemTemplate = tfBottom.ItemTemplate;
-
-
DataTable dt=getData();
-
dataListBottom.DataSource = dt;
-
dataListBottom.DataBind();
-
-
} //end of if
-
-
}//end of method
-
-
-
//itemcommand event definition
-
void dataListBottom_ItemCommand(object source, DataListCommandEventArgs e)
-
{
-
dataListUpdate(e);
-
}
-
-
}//end of class
-
-
//here is my class for Itemplate with a linkbutton
-
public class GridViewTemplate : ITemplate
-
{
-
private DataControlRowType templateType;
-
private string columnName;
-
-
public GridViewTemplate(DataControlRowType type, string colname)
-
{
-
templateType = type;
-
columnName = colname;
-
}
-
-
public void InstantiateIn(System.Web.UI.Control container)
-
{
-
// Create the content for the different row types.
-
switch (templateType)
-
{
-
case DataControlRowType.Header:
-
-
break;
-
case DataControlRowType.DataRow:
-
LinkButton lnkbSPDesc = new LinkButton();
-
lnkbSPDesc.DataBinding += new EventHandler(lnkbSPDesc_DataBinding);
-
lnkbSPDesc.Click += new EventHandler(lnkbSPDesc_Click);
-
container.Controls.Add(lnkbSPDesc);
-
break;
-
-
-
default:
-
break;
-
}
-
}
-
-
void lnkbSPDesc_Click(object sender, EventArgs e)
-
{
-
LinkButton lb = (LinkButton)sender;
-
-
}
-
-
void lnkbSPDesc_DataBinding(object sender, EventArgs e)
-
{
-
-
LinkButton l = (LinkButton)sender;
-
//Label l = (Label)sender;
-
-
DataListItem item = (DataListItem)l.NamingContainer;
-
-
-
POAICSharepointUtility.GetConfigKey("");
-
l.Text = DataBinder.Eval(item.DataItem, POAICSharepointUtility.GetConfigKey("SalesPositionDescriptionColumn")).ToString();
-
l.CommandArgument = DataBinder.Eval(item.DataItem, POAICSharepointUtility.GetConfigKey("SalesPositionIdColumn")).ToString();
-
l.CommandName = DataBinder.Eval(item.DataItem, POAICSharepointUtility.GetConfigKey("SalesPositionIdColumn")).ToString();
-
l.Click += new EventHandler(l_Click);
-
} //end of class
I hope this code will help you for understanding my problem.
looking for your reply.
thank you
Hi
I dont know what happend, but now my problem was solved. The datalist itemcommand event firing is working fine.
Thank you.
Frinavale 9,735
Recognized Expert Moderator Expert
I'm glad that you solved your problem.
Hopefully next time we'll actually be able to help you :)
-Frinny
Yes frinny. i hope the same.
Hi Frinny
I struck with a problem for Dyanamic Grid View. i am generating a dynamic gridview by custom ItemTemplate. every thing is working except the Page Size. my gridview it not showing records in page wise even i set page size property. where as it is showing all data in 1 page.
In my code, i am only considering ItemTemplate. i am not at all considering PageSetting or PageTemplate. but i am setting gridview's page size property.
the result i am getting is all data that i will give as source to gridview are getting populated on 1 page instead of n pages that i will get with respect to my page size value.
can you explain how i can get my data populate in several pages.
Frinavale 9,735
Recognized Expert Moderator Expert
It should work...
Did you set AllowPaging="tr ue"?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: HarveyB |
last post by:
I would like to generate non-modal popup windows from
ASP.Net code-behind. I have tried using Client Side
scripting like "function Test(){
window.open('test.htm',_blank,
'height=200,width=400,status=no,toolbar=no,
menubar=no,location=no resizable=no
scrollable=no');
but I can't seem to invoke the client side script from
within a Server Side Form. I know I can use the context
with to Response.redirect or Server.transfer to return a
|
by: Mark |
last post by:
I have been working for quite some time on this issue which in theory
should be quite simple. The problem is that the Cancel and Save
events are not fired when their respective buttons are clicked.
I have read several posts which say to put your column generating
section in the Page_Init section and it will solve the
problem....however, it hasn't solved mine.
Can somebody please take a look at this and provide any insight if
possible?
|
by: usl2222 |
last post by:
Hi folks,
I appreciate any assistance in the following problem:
I have a form with a bunch of dynamic controls on it. All the controls
are dynamically generated on a server, including all the validators.
The user enters the data, presses OK. My OK button is dynamically
generated as well, with some code-behind logic in
|
by: Neil Jarman |
last post by:
Hi,
I'm new to this today, and I've got some test code (see below.) The data
loads fine.
I can't understand why any of the events fire. Once the page loads, clicking
on thew button from the ItemTemplate does not fire the OnItemCommand event.
It just fires a page reload - as a postback.
I guess I'm missing something really obvious and important here?
|
by: Daniela Roman |
last post by:
Hello,
I try to fire an event under a button click event and maybe anybody can give
a clue please.
I have let's say a WEB grid with PageIndexChanged event:
private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
| |
by: erdos |
last post by:
I have an asp.net 2.0 button with server and client side click
events. On the first click, both events will fire. On the next
click, only the client side event fires. How do I make the server
side event not fire after the first click?
Thanks,
Brett
|
by: John Kotuby |
last post by:
Hi guys,
I am converting a rather complicated database driven Web application from
classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The
original ASP application works quite well, so at times it is tempting just
to port parts of it over mostly as-is. In fact, one MSDN article I read
suggested using straight HTML wherever possible to make the app more
efficient and less resource demanding.
On one page there are 2...
|
by: Vili |
last post by:
Hi all
I am having a problem here
Is it possible to fire a server side function from client side?
ie. I have a function on codebehind
Sub DoSomething(o as object)
|
by: Crazy Cat |
last post by:
Hi all,
I am developing an asp.net 2.0 application in Visual Studio 2005. On
my page I have a simple datalist that is bound programmatically to a
collection of simple objects. On this page I need to control the
visibility of a textbox based on a dropdown selection in the
datalist's edititem template. To do this, I registered a client script
block function and attached a client side handler for the
dropdownlist's onchange event in the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |