473,509 Members | 7,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding attributes to page button of datagrid

Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
Nov 18 '05 #1
8 4423
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is created using
[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browser can
vary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of pagebutton so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

Nov 18 '05 #2
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is created using
[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browser can
vary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of pagebutton so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

Nov 18 '05 #3
Hi Alex,

Thanks a lot!
I tried the same thing in DataItembound event of datagrid
but it If condition falied there,,,

Is DataItembound doesnt get Pager item and Item_Created
can have that item??

Please suggest
-----Original Message-----
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is created using
[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browser can
vary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of

page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

.

Nov 18 '05 #4
Hi Alex,

Thanks a lot!
I tried the same thing in DataItembound event of datagrid
but it If condition falied there,,,

Is DataItembound doesnt get Pager item and Item_Created
can have that item??

Please suggest
-----Original Message-----
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is created using
[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browser can
vary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of

page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

.

Nov 18 '05 #5
yes, the ItemDataBound event doesn't trap the pager item -
you need to use the ItemCreated event.

alex
-----Original Message-----
Hi Alex,

Thanks a lot!
I tried the same thing in DataItembound event of datagridbut it If condition falied there,,,

Is DataItembound doesnt get Pager item and Item_Created
can have that item??

Please suggest
-----Original Message-----
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is created using[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browser canvary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of

page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

.

.

Nov 18 '05 #6
yes, the ItemDataBound event doesn't trap the pager item -
you need to use the ItemCreated event.

alex
-----Original Message-----
Hi Alex,

Thanks a lot!
I tried the same thing in DataItembound event of datagridbut it If condition falied there,,,

Is DataItembound doesnt get Pager item and Item_Created
can have that item??

Please suggest
-----Original Message-----
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is created using[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browser canvary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of

page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

.

.

Nov 18 '05 #7
Yes, Now in Item_Created event, If conditions goes well
but it gives only one cell and one control for that i.e
Label,,but i need to get that page button (1,2,3....)

the code is:

private void dgSearchedAltPackages_ItemCreated(object
sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Pager )
{
foreach(Control ctrl in e.Item.Controls)
{
Response.Write("ctrl type" + ((Label)ctrl.Controls
[0]).GetType() +"<br>");
}
}
}

It prints only Label and no Button UI type??

Please suggest!!

Thanks,
Sumit
-----Original Message-----
yes, the ItemDataBound event doesn't trap the pager item -
you need to use the ItemCreated event.

alex
-----Original Message-----
Hi Alex,

Thanks a lot!
I tried the same thing in DataItembound event of

datagrid
but it If condition falied there,,,

Is DataItembound doesnt get Pager item and Item_Created
can have that item??

Please suggest
-----Original Message-----
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is createdusing[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browsercanvary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of
page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

.

.

.

Nov 18 '05 #8
Hi,

Thanks a lot!!
It is done!!

Sumit
-----Original Message-----
yes, the ItemDataBound event doesn't trap the pager item -
you need to use the ItemCreated event.

alex
-----Original Message-----
Hi Alex,

Thanks a lot!
I tried the same thing in DataItembound event of

datagrid
but it If condition falied there,,,

Is DataItembound doesnt get Pager item and Item_Created
can have that item??

Please suggest
-----Original Message-----
Hi Sumit

in the Item_Created event of the datagrid you can trap
the iteration for when the Pager row item is createdusing[C#]
if (e.Item.ItemType == ListItemType.Pager)

the way asp.net renders the pager row to the browsercanvary - it usually creates a single table-cell and fills
this cell with controls containing the paging buttons.

To extract the attributes collection of the control you
want to access you can use
[C#]
e.Item.Cells[index].Controls[index].Attributes

or e.Item.Cells[index].FindControl(name)
alex
-----Original Message-----
Hi,

I want to add one java script function on the click of
page button of datagrid. But how to get UI control of
page
button so that i should be able to add attribute for
onClick event.

Please suggest

Sumit
.

.

.

.

Nov 18 '05 #9

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

Similar topics

2
3615
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
3
4856
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
321
by: sumit | last post by:
Hi, I want to add one java script function on the click of page button of datagrid. But how to get UI control of page button so that i should be able to add attribute for onClick event. ...
4
5570
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
1
3261
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
19
2443
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do...
4
1895
by: Craig G | last post by:
i was using the following on a serverside button on a form If (Not Page.IsPostBack) Then Me.BtnDelete.Attributes.Add("onclick","return confirm('Are you sure you want to delete?');") End If ...
5
1929
by: Samy | last post by:
Hi There, I have a label in a datagrid which I make it a input type = radio in ItemDataBound so that radio buttons are shown in the datagrid. This is how I have it... ASPX... <asp:Label...
2
3102
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
0
7416
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
5656
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,...
1
5062
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...
0
4732
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...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
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...

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.