473,795 Members | 3,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

link data grid edit button

Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some client events (such
as message box,
and do another event just after that to the server (do some manipulation on
the database).

If I cannot - how can I do that anyway in some tricky way ?

Thanks :)

Nov 19 '05 #1
13 1423
There is no limit in programming:)))

Create a web control library named as MyControlLibrar y and following code...
And use this control in anywhere... Feel free to built on something on
this....

using System;
using System.Web.UI;
using System.Web.UI.W ebControls;

namespace MyControlLibrar y
{
[System.Componen tModel.DefaultP roperty("Text") ,
ToolboxData("<{ 0}:MyLinkButton runat=server></{0}:MyLinkButto n>")]
public class MyLinkButton : System.Web.UI.W ebControls.Link Button
{
string question="?";
[System.Componen tModel.Bindable (true)]
public String Question
{
get
{
return question;
}
set
{
question="";
}
}
protected override void Render(HtmlText Writer output)
{
Attributes.Add( "onClick",Strin g.Format("javas cript:return
confirm('{0}')" ,Question));
base.Render(out put);
}
}
}
--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"John M" <nobody@nospam_ please.com> wrote in message
news:OR******** ******@TK2MSFTN GP15.phx.gbl...
Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some client events (such
as message box,
and do another event just after that to the server (do some manipulation
on
the database).

If I cannot - how can I do that anyway in some tricky way ?

Thanks :)

Nov 19 '05 #2
.... and how can I make a web-control library (file - > new ??? ... )

Thanks :)

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakadem ik.net> wrote in message
news:eB******** ******@TK2MSFTN GP09.phx.gbl...
There is no limit in programming:)))

Create a web control library named as MyControlLibrar y and following
code... And use this control in anywhere... Feel free to built on
something on this....

using System;
using System.Web.UI;
using System.Web.UI.W ebControls;

namespace MyControlLibrar y
{
[System.Componen tModel.DefaultP roperty("Text") ,
ToolboxData("<{ 0}:MyLinkButton runat=server></{0}:MyLinkButto n>")]
public class MyLinkButton : System.Web.UI.W ebControls.Link Button
{
string question="?";
[System.Componen tModel.Bindable (true)]
public String Question
{
get
{
return question;
}
set
{
question="";
}
}
protected override void Render(HtmlText Writer output)
{
Attributes.Add( "onClick",Strin g.Format("javas cript:return
confirm('{0}')" ,Question));
base.Render(out put);
}
}
}
--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"John M" <nobody@nospam_ please.com> wrote in message
news:OR******** ******@TK2MSFTN GP15.phx.gbl...
Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some client events
(such
as message box,
and do another event just after that to the server (do some manipulation
on
the database).

If I cannot - how can I do that anyway in some tricky way ?

Thanks :)


Nov 19 '05 #3
Hi John,

You can use buttonObject.At tributes.Add method add client-
side javascript method. Following code snippet shows how
to add client-side message box code:

Suppose you have EditCommandColu mn as the first column of
the datagrid. In datagrid_ItemDa taBound event:

if (e.Item.ItemTyp e == ListItemType.It em ||
e.Item.ItemType == ListItemType.Al ternatingItem )
{
LinkButton editBtn = (LinkButton)e.I tem.Cells
[0].Controls[0];
editBtn.Attribu tes.Add("Onclic k","alert('E dit
Message');");
}

HTH

Elton Wang
el********@hotm ail.com

-----Original Message-----
Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some client events (suchas message box,
and do another event just after that to the server (do some manipulation onthe database).

If I cannot - how can I do that anyway in some tricky way ?
Thanks :)

.

Nov 19 '05 #4
New Web Control Library

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"John M" <nobody@nospam_ please.com> wrote in message
news:OA******** ******@TK2MSFTN GP14.phx.gbl...
... and how can I make a web-control library (file - > new ??? ... )

Thanks :)

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakadem ik.net> wrote in message
news:eB******** ******@TK2MSFTN GP09.phx.gbl...
There is no limit in programming:)))

Create a web control library named as MyControlLibrar y and following
code... And use this control in anywhere... Feel free to built on
something on this....

using System;
using System.Web.UI;
using System.Web.UI.W ebControls;

namespace MyControlLibrar y
{
[System.Componen tModel.DefaultP roperty("Text") ,
ToolboxData("<{ 0}:MyLinkButton runat=server></{0}:MyLinkButto n>")]
public class MyLinkButton : System.Web.UI.W ebControls.Link Button
{
string question="?";
[System.Componen tModel.Bindable (true)]
public String Question
{
get
{
return question;
}
set
{
question="";
}
}
protected override void Render(HtmlText Writer output)
{
Attributes.Add( "onClick",Strin g.Format("javas cript:return
confirm('{0}')" ,Question));
base.Render(out put);
}
}
}
--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"John M" <nobody@nospam_ please.com> wrote in message
news:OR******** ******@TK2MSFTN GP15.phx.gbl...
Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some client events
(such
as message box,
and do another event just after that to the server (do some manipulation
on
the database).

If I cannot - how can I do that anyway in some tricky way ?

Thanks :)



Nov 19 '05 #5
Good,

I have tried the following vb code,
but (I have three columns, one is the "edit").
cn.controls.cou nt is always 0
(I have tried to change e.item.cell(0), e.item.cell(1), e.item.cell(2) )

So I didn't manage running the code.

Thanks :)

Dim editBtn As LinkButton
Dim cn As Control
Dim c As TableCell
If e.Item.ItemType = ListItemType.It em Or ListItemType.Al ternatingItem Then
c = e.Item.Cells(0)
cn = c
editBtn = cn.Controls(0)
editBtn.Attribu tes.Add("Onclic k", "Alert('Edi t Message')")
End If

"Elton W" <an*******@disc ussions.microso ft.com> wrote in message
news:1c******** *************** *****@phx.gbl.. .
Hi John,

You can use buttonObject.At tributes.Add method add client-
side javascript method. Following code snippet shows how
to add client-side message box code:

Suppose you have EditCommandColu mn as the first column of
the datagrid. In datagrid_ItemDa taBound event:

if (e.Item.ItemTyp e == ListItemType.It em ||
e.Item.ItemType == ListItemType.Al ternatingItem )
{
LinkButton editBtn = (LinkButton)e.I tem.Cells
[0].Controls[0];
editBtn.Attribu tes.Add("Onclic k","alert('E dit
Message');");
}

HTH

Elton Wang
el********@hotm ail.com

-----Original Message-----
Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some

client events (such
as message box,
and do another event just after that to the server (do

some manipulation on
the database).

If I cannot - how can I do that anyway in some tricky

way ?

Thanks :)

.

Nov 19 '05 #6
Could you show your html code of datagrid?

Elton

"John M" wrote:
Good,

I have tried the following vb code,
but (I have three columns, one is the "edit").
cn.controls.cou nt is always 0
(I have tried to change e.item.cell(0), e.item.cell(1), e.item.cell(2) )

So I didn't manage running the code.

Thanks :)

Dim editBtn As LinkButton
Dim cn As Control
Dim c As TableCell
If e.Item.ItemType = ListItemType.It em Or ListItemType.Al ternatingItem Then
c = e.Item.Cells(0)
cn = c
editBtn = cn.Controls(0)
editBtn.Attribu tes.Add("Onclic k", "Alert('Edi t Message')")
End If

"Elton W" <an*******@disc ussions.microso ft.com> wrote in message
news:1c******** *************** *****@phx.gbl.. .
Hi John,

You can use buttonObject.At tributes.Add method add client-
side javascript method. Following code snippet shows how
to add client-side message box code:

Suppose you have EditCommandColu mn as the first column of
the datagrid. In datagrid_ItemDa taBound event:

if (e.Item.ItemTyp e == ListItemType.It em ||
e.Item.ItemType == ListItemType.Al ternatingItem )
{
LinkButton editBtn = (LinkButton)e.I tem.Cells
[0].Controls[0];
editBtn.Attribu tes.Add("Onclic k","alert('E dit
Message');");
}

HTH

Elton Wang
el********@hotm ail.com

-----Original Message-----
Hello,

In Visual studio .NET 2003,

On datagrid object :
How can I link the button element : edit, to do a some

client events (such
as message box,
and do another event just after that to the server (do

some manipulation on
the database).

If I cannot - how can I do that anyway in some tricky

way ?

Thanks :)

.


Nov 19 '05 #7
Sorry. I can't find attachment.

"John M" wrote:

See as attached file.

Thanks :)

Nov 19 '05 #8
Hi John,

I suppose index = 2 should work. Anyway, try foolowing code:

Dim editBtn As LinkButton
If e.Item.ItemType = ListItemType.It em OrElse ListItemType.Al ternatingItem
Then
editBtn = CType(e.Item.Ce lls(2).Controls (0), LinkButton)
editBtn.Attribu tes.Add("Onclic k", "Alert('Edi t Message')")
End If

HTH

Elton
"John M" wrote:

"Elton W" <El****@discuss ions.microsoft. com> wrote in message
news:36******** *************** ***********@mic rosoft.com...
Sorry. I can't find attachment.


Maybe your outlook express block the attachment.
Here is again.

Here is the code, as follows :
Thanks :)
----------------------------------------

<%@ Page Language="vb" AutoEventWireup ="false" Codebehind="Web Form1.aspx.vb"
Inherits="WebAp plication1.WebF orm1" debug="False"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta content="False" name="vs_showGr id">
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
</HEAD>
<body bgColor="#ffccf f" MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">

<asp:datagrid id="DataGrid1" style="Z-INDEX: 105; LEFT: 488px; POSITION:
absolute; TOP: 40px"
runat="server" HorizontalAlign ="Left" ShowFooter="Tru e" CellSpacing="2"
CellPadding="3" BorderWidth="1p x"
BorderStyle="No ne" AutoGenerateCol umns="False" Caption="a list"
BorderColor="#C 0FFC0" BackColor="#FFF FC0"
AllowPaging="Tr ue">
<FooterStyle ForeColor="#8C4 510" BackColor="#F7D FB5"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" Wrap="False" ForeColor="Whit e"
BackColor="#738 A9C"></SelectedItemSty le>
<ItemStyle Wrap="False" HorizontalAlign ="Right" ForeColor="#8C4 510"
BackColor="#FFF 7E7"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign ="Right" ForeColor="Whit e"
BackColor="#A55 129"></HeaderStyle>
<Columns>
<asp:BoundColum n DataField="firs tname" HeaderText="fir st name">
<HeaderStyle Wrap="False" HorizontalAlign ="Right"
Width="0px"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign ="Right"></ItemStyle>
<FooterStyle Wrap="False" HorizontalAlign ="Right"></FooterStyle>
</asp:BoundColumn >
<asp:BoundColum n DataField="last name" HeaderText="las t name">
<HeaderStyle Wrap="False" Width="0px"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="upd ate"
CancelText="can cel" EditText="delet e">
<HeaderStyle Wrap="False" Width="0px"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<FooterStyle Wrap="False"></FooterStyle>
</asp:EditCommand Column>
</Columns>
<PagerStyle HorizontalAlign ="Center" ForeColor="#8C4 510"
Mode="NumericPa ges"></PagerStyle>
</asp:datagrid></form>
</body>
</HTML>

Nov 19 '05 #9

"Elton W" <El****@discuss ions.microsoft. com> wrote in message
news:78******** *************** ***********@mic rosoft.com...
Hi John,

I suppose index = 2 should work. Anyway, try foolowing code:

Dim editBtn As LinkButton
If e.Item.ItemType = ListItemType.It em OrElse ListItemType.Al ternatingItem
Then
editBtn = CType(e.Item.Ce lls(2).Controls (0), LinkButton)
editBtn.Attribu tes.Add("Onclic k", "Alert('Edi t Message')")
End If

HTH

Elton
"John M" wrote:

I did as your advise.

Still,
controls.count is 0,
so the code run of exception outofrange.
(Maybe not "controls", but something else).

Thanks :)
Nov 19 '05 #10

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

Similar topics

3
2221
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of columns. & depending on what the user enters, the data grid can grow very large. So to avoid scrolling the whole page, I just want the data grid to be scrollable. For this I used the <div> tags around the data grid, <div...
5
2795
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
2
2985
by: Remy | last post by:
Hi I would like to put a link into the Footer of the first column of an ASP.NET 2.0 GridView. By first column I mean the column where it normally displayes the Edit and Delete link. I've built the Insert functionality into the footer, but I only wanna display those controls if someone clicks on the link. At the moment I hide the whole footer and I have the link outside of the grid. I guess I could just add another table below the grid...
10
2932
by: Corey B | last post by:
I have a data grid that has three columns: First Name, Middle Name, and Last Name. The grid has a list of people with a blank row at the bottom of the grid (in the footer) that allows the user to add a new person to the list. There is also an Edit button at the end of each row that allows the user to edit a particular row. So far - no problem - easy to do. I have been asked to make the grid section 508 compliant. The requirement is...
0
1424
by: anwarulhuq | last post by:
I have placed Edit-Update-Cancel Link button from Properties builder of the Data Grid. Its working but the problem what im facing is.. It doesnt work till i click for two times. Link button should work for only one click right. Please help me out to solve this.
2
1485
by: Bazza Formez | last post by:
Hello, In my aspx file I have a LinkButton inside a template column, inside a datagrid. I have assigned a CommandName to the button. In my code behind, I attempt to trap the command in the ItemCooamd for the Datagrid. I have used this successfully before with no problems. This time however, the button will not fire ItemCommand.
3
2342
by: kevinpublic | last post by:
I have an item list for ordered products on a data grid in VS 2003. It's an ASP page running VB behind it. All detail lines display as well as all shipping charges. On the edit screen, we allow them to cancel individual line items. We have the 'Cancel' button enabled for the line items of the datagrid. However, I would like to hide that button for the shipping charges. We don't want them cancelling their shipping fees, after all. ...
1
1415
by: rktester | last post by:
Hi, I am trying to implement an editable datagrid in .net 2005 This is how my grid is defined: <asp:DataGrid runat="server" id="dgUser" Font-Name="Verdana" Font-Size="9pt" CellPadding="5" AlternatingItemStyle-BackColor="#dddddd" AutoGenerateColumns="False" DataKeyField="UserId"
0
1049
by: ravindarjobs | last post by:
hello friends, i am using vb6. i am using a datagrid on my form. i am showing a table data in that grid. i have enabled the grid property " allow to add new rows" and" allow edit" here are my few doubts and requirements 1. there will be an empty row shown at the last row by default. when we insert data in to that row, another empty row will automatically created. my requirement is such that, when new row comes automatically, its...
0
9672
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, 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...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
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, 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...
0
10214
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 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...
0
10001
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 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...
1
7538
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 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...
0
6780
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();...
0
5437
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...
3
2920
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 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...

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.