Hey all. hope someone can give me a little advice here.
I have a GridView, and on each line of it there's an
<asp:imagebutto nlike this:
<asp:ImageButto n ID="hlCancel" runat="server" ImageUrl="/details.png"
Width="10px" Height="10px" OnClick=<%#
showDetails(Htt pUtility.HtmlEn code(Convert.To String(Eval("id "))))
%/
The thing is, I need the OnClick event on each line to call the
method showDetails with the ID related to it, like showDetails(LIN E
ID), but this binding tag, while working normally on normal fields
(like label's TEXT) doesn't work here.
I think the error is CASTING related... but Im not sure. I also
tried
to create a function to return the string "showDetails(id )", but it
gives me an InvalidPostback error...
Anyone have a tutorial or lessons on binding with functions/methods ? 4 3531
Use the standard events rather than trying to kludge this together. There
are plenty of tutorials on the web on getting the ID from a postback,
without attempting to call a custom server side event.
if you must have a call that is fired onClick, you can do something like the
following; http://www.codeproject.com/useritems...agridclick.asp
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"Jl_G_0" <jl*********@gm ail.comwrote in message
news:11******** *************@k 79g2000hse.goog legroups.com...
Hey all. hope someone can give me a little advice here.
I have a GridView, and on each line of it there's an
<asp:imagebutto nlike this:
<asp:ImageButto n ID="hlCancel" runat="server" ImageUrl="/details.png"
Width="10px" Height="10px" OnClick=<%#
showDetails(Htt pUtility.HtmlEn code(Convert.To String(Eval("id "))))
%/
The thing is, I need the OnClick event on each line to call the
method showDetails with the ID related to it, like showDetails(LIN E
ID), but this binding tag, while working normally on normal fields
(like label's TEXT) doesn't work here.
I think the error is CASTING related... but Im not sure. I also
tried
to create a function to return the string "showDetails(id )", but it
gives me an InvalidPostback error...
Anyone have a tutorial or lessons on binding with functions/methods ?
the OnClick is a serverside event for which you cannot change the signature.
the property is expecting the name of a function (with the proper parameter
list),
if you where trying to call client script, see the OnClicntClick property.
-- bruce (sqlwork.com)
"Jl_G_0" wrote:
Hey all. hope someone can give me a little advice here.
I have a GridView, and on each line of it there's an
<asp:imagebutto nlike this:
<asp:ImageButto n ID="hlCancel" runat="server" ImageUrl="/details.png"
Width="10px" Height="10px" OnClick=<%#
showDetails(Htt pUtility.HtmlEn code(Convert.To String(Eval("id "))))
%/
The thing is, I need the OnClick event on each line to call the
method showDetails with the ID related to it, like showDetails(LIN E
ID), but this binding tag, while working normally on normal fields
(like label's TEXT) doesn't work here.
I think the error is CASTING related... but Im not sure. I also
tried
to create a function to return the string "showDetails(id )", but it
gives me an InvalidPostback error...
Anyone have a tutorial or lessons on binding with functions/methods ?
thx. I'll have a look at these links. The reason I wanted to do this
its because I tried to do several functions inside the same aspx page,
with UpdatePanels and dynamic stuff. I was avoiding postbacks and pop-
ups to show details...
Working now - just reporting what I did, maybe someone will need:
The method gets the sender AND its CommandArgument , since the
CommandArgument is a string, it can be bound to the ID field. So the
method gets the sender and then the ID of the gridview element.
void showDetails(obj ect sender, EventArgs e)
{
//HERE I CREATE AN INSTANCE FOR THE BUTTON
ImageButton bot = (ImageButton)se nder;
//NOW YOU GET THE COMMAND ARGUMENT
string argument1 = bot.CommandArgu ment.ToString() ;
//AND FINALLY YOU CAN USE IT THE WAY YOU WANT
string sql = "SELECT * FROM tbl01 WHERE id=" + argument1;
......
}
Here's the code for the button, OnClick calls the method above,
CommandArgument is bound to the ID field of my database:
<asp:ImageButto n ID="hlCancelx" runat="server" ImageUrl="~/
details.png" Width="10px" Height="10px" OnClick="showDe tails"
CommandArgument ='<%#
HttpUtility.Htm lEncode(Convert .ToString(Eval( "id"))) %>'/>
The downside: I had to switch EnableEventVali dation to "false" on the
page... but I think it can't be helped...
Thanks for the help, I researched based on what you guys told me. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: LU |
last post by:
I have a datagrid for viewing and deleting. Under that I
have a drop down with binded info and a button to add the
select drop down item into database.
1User can view datagrid and delete info.
2User can select from drop down, click add button and add
selection to database.
A)Datagrid binds and deletes fine.
B)If I select the first value of drop down addition to
database works fine.
C)<problem>if I select the 2nd value of drop down it...
|
by: Stephen |
last post by:
Hey everyone. I was wondering if someone could help me with a small problem.
I have designed a user control and I would have inserted it on a aspz page
(WebForm1). The User control is being used to help with the navigation
through a datagrid. The control handles all the paging issues and on the
webform I do all the DataBinding.
My problem is that at the end of code of an on-click event for a link button
on my user control...
|
by: Stephen |
last post by:
Hey everyone. I was wondering if someone could help me with a small problem.
I have designed a user control and I would have inserted it on a aspz page
(WebForm1). The User control is being used to help with the navigation
through a datagrid. The control handles all the paging issues and on the
webform I do all the DataBinding.
My problem is that at the end of code of an on-click event for a link button
on my user control...
|
by: Marty McDonald |
last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate
a DataTable whose data should appear in the asp:Table. I created my own
code to populate the asp:Table with the DataTable, then I discovered the
asp:Table has a DataBind method. But the method takes no args and so I'm
confused how to use it. Is there a link to see how DataBind works for
asp:Table? Should I just use my own code anyway? Thanks...
Here's my...
|
by: Diane Yocom |
last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but...
I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where there are tabs at the top with "submenu" buttons showing below the selected tab. The data that defines the tabs and submenus is stored in an XML file and I'm using nested repeaters to build them dynamically.
I've got it working pretty well, except...
| |
by: simon |
last post by:
If I put button into the header of my DataGrid:
<asp:TemplateColumn>
<HeaderTemplate><asp:Button ID=btnNew Text="New Type"
Runat=server></asp:Button></HeaderTemplate>
<ItemTemplate>
.....
and in codeBehind:
|
by: martyn_wynne |
last post by:
Hi,
I have found a odd one, my submit button is not submitting on a
method="get" form after using any form of DataBind?
Has anyone struck this problem before?
here is snipits of the code as an example
<form id="frmUserSearch" method="get" runat="server">
|
by: Nemo |
last post by:
Hi.
I Have a CheckBoxList and I would like the add the onclick attribute. But
when I add the attribute only the first one in my list get the onclick
attribute.
Here is my code.
protected CheckBoxList myCheckBoxList;
|
by: Ryan |
last post by:
Hello,
I have a standard HTML button on an aspx web form that I have set to
runat server. The button is named reset1 and its tag is as follows:
<INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset"
value="Reset" name="btnReset1" runat="server">
Using Interdev I then double click the button in design view and in the
code behind page (aspx.vb) have the following:
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |