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

How to? AutoGenerateSelectButton manually

A GridView control in ASP.NET has the option to Auto-Generate the
select button (which is a link that calls __doPostBack which I presume
does a post-back to the server). Is there information on how to
generate this __doPostBack function manually?

The motivation is simple. Using the same __doPostBack([tablename],
'Select$[table row index]') function generated on the 'Select' button
link from AutoGenerateSelectButton flag being set to true, I have made
it so that whenever you click on a row in the GridView, it executes as
if the select button was clicked. However, if I remove the
AutoGenerateSelectButton property, the __doPostBack function is no
longer defined. This is quite annoying because the 'Select' button is
ugly and takes away from the ease of use.

I haven't found much information on this, so any would be greatly
appreciated.

Mar 31 '06 #1
3 4447
well, what you are looking for is the GetPostBackEventReference()
method. you can inject that into the javascript onclick event or
whatever for the table row, i believe, but i have not done it myself.
you will want to create the table yourself.

hopefully this gives you the start that you need, if you need more
help, shoot me an email.

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 31 '06 #2
Ahh, thank you very much. I will try that and let you know how it goes.

Apr 3 '06 #3
Ok, after some playing around I got it. I'm going to post it here for
all those that might come across this issue.

Here's the progression that I imagine most people inexperienced at this
(like me) will go through.

In Page_Load:
if (!IsPostBack){
[...]
// Add __getPostBack to onclick handler for a gridview row
for (int i=0; i < myGridView.Rows.Count; i++)
{
myGridView.Rows[i].Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(myGridView, "Select$"+i));
}
}

But this still doesn't work. You must add to the @Page directive
EnableEventValidation="false". This may raise some security issues to
be dealt with later.

Ok, so at this point, you can remove the AutoGenerateSelectButton
attribute from the GridView and it will work. However, once the
Postback is performed, __doPostBack is no longer registered. Simply
move the loop out of the "if(!IsPostBack)" scope and it's all set.

Thanks for the info, Darren Kopp.

Apr 3 '06 #4

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

Similar topics

2
by: | last post by:
I would like to add a reference to my project manually. Is there somewhere in the IDE where I can see and modify all of this project's references? Thanks, VM
1
by: VM | last post by:
How can I manually run the code of an event? For example, I want to run a Mouse click event without actually clicking doing a Mouse click? Thanks.
6
by: Karl Hungus | last post by:
Im using an xsl transformation so its not practical to use controls in the usual way, but I would still like to call methods in my codebehind class. usually Id just use onclick="<eventHandler>"...
0
by: Marc Callec | last post by:
I'm trying to create an instance of the CrystalReportViewer control within my class in an attempt to return the rendered HTML back to the consumer of the class. Because I haven't added the...
1
by: Bob | last post by:
For an assembly I manually load from a file, this code snippet: For Each t As Type In asm.GetTypes 'do something Next generates this error message: ...
4
by: Brian Mitchell | last post by:
How do you fire a toolbar ButtonClick event manually (for a specified button)? I have a toolbar with 4 buttons on it and I want to fire one of the button events when the user clicks a different...
3
by: darrel | last post by:
I have three tables making a many-to-many relationship: Companies CoID | CoName Link CoID | InsID Insurers InsID | InsName
3
by: mayur_hirpara | last post by:
Hi, I am writing a VB.NET application. It is a Windows application at the moment. The application contains a button. the click event of button perform a long running task. It needs to be started...
1
by: Ethender | last post by:
Hi, How to execute Process-flows manually(from SQLPLUS). I tried to execute the process-flows manually by using the following, but no response. sqlplus OWB/OWB@sa...
1
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...
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
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

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.