473,761 Members | 7,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid asp:EditCommand Column with Creating Templates in a progra

Hi,

The DataGrid aps:EditCommand Column when used with column templates created
programmaticall y does not trigger the _Edit subroutine in code. The
ASP:Datagrid definition is below (1), the _Edit subroutine signature (2) is
below that and the column template class is (3).

Thank you for your help,

Scott

1)
<ASP:DATAGRID id="MyDataGrid " runat="server" AutoGenerateCol umns="False"
AllowSorting="T rue"
Font-Names="Verdana" AlternatingItem Style-BackColor="Gain sboro"
OnItemDataBound ="MyDataGrid_It emBound" ShowFooter="Tru e"
OnSortCommand=" MyDataGrid_Sort Command" OnEditCommand=" MyDataGrid_Edit "
OnCancelCommand ="MyDataGrid_Ca ncel"
onDeleteCommand ="MyDataGrid_De leteCommand"
OnUpdateCommand ="MyDataGrid_Up date" BorderWidth="1p x"
Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaa add"
BorderColor="Bl ack" CellPadding="3" Height="441px">
<HeaderStyle BackColor="#AAA ADD" Wrap="False"></HeaderStyle>

<Columns>
<asp:EditComman dColumn ButtonType="Pus hButton" UpdateText="Ok"
HeaderText="Edi t Info" CancelText="Can cel" EditText="Edit" >
<HeaderStyle Wrap="False" HorizontalAlign ="Center" Width="50px"></HeaderStyle>
<ItemStyle Wrap="False" Width="50px"></ItemStyle>
</asp:EditCommand Column>
</Columns>
</ASP:DATAGRID>

2)
Sub MyDataGrid_Edit (ByVal sender As Object, ByVal e As _
DataGridCommand EventArgs)
..
..
..
End Sub

The column templates are created with by calling the custom Templates column:

3)
Public Class DynamicDataGrid Template
Implements ITemplate
Dim templateType As ListItemType
Dim columnName As String
Dim ColumnNum As Integer

Sub New(ByVal type As ListItemType, ByVal ColName As String, ByVal ColNum
As Integer)
templateType = type
columnName = ColName
columnNum = ColNum
End Sub

Sub InstantiateIn(B yVal container As Control) _
Implements ITemplate.Insta ntiateIn

Dim lc As New Literal
Dim chkBox1 As New CheckBox
Dim chkBox2 As New CheckBox
Select Case templateType
Case ListItemType.He ader
If ColumnNum = 0 Then
lc.Text = "<B>" & columnName & "</B><BR>"
container.Contr ols.Add(lc)
Else
lc.Text = "<B>" & columnName & "</B><BR>"
container.Contr ols.Add(lc)
If ColumnNum = 1 Then
chkBox1.Text = "Asc"
If columnName.Star tsWith("Acad") Then
chkBox1.Checked = False
Else
chkBox1.Checked = True
End If

chkBox1.ID = "chkBox" & ColumnNum
container.Contr ols.Add(chkBox1 )
If columnName.Star tsWith("Acad") Then
chkBox2.Checked = True
Else
chkBox2.Checked = False
End If
chkBox2.Text = "Desc"
chkBox2.ID = "chkBox" & ColumnNum
container.Contr ols.Add(chkBox2 )
Else
chkBox1.Text = "Asc"
chkBox1.ID = "chkBox" & ColumnNum
container.Contr ols.Add(chkBox1 )
chkBox2.Text = "Desc"
chkBox2.ID = "chkBox" & ColumnNum
container.Contr ols.Add(chkBox2 )
End If
End If
Case ListItemType.It em
lc.Text = "Item " & columnName
container.Contr ols.Add(lc)
Case ListItemType.Ed itItem
Dim tb As New TextBox
tb.Text = ""
container.Contr ols.Add(tb)
Case ListItemType.Fo oter
lc.Text = "<I>Footer</I>"
container.Contr ols.Add(lc)
End Select
End Sub
End Class

Jun 19 '06 #1
0 1244

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

Similar topics

0
1023
by: Tom | last post by:
Does anyone know of a way to format this column at run time? I have a datagrid with one bound column plus the Edit, Update and Cancel buttons. When I press the Edit button, the text box surrounding my one column field does not size itself to the content returned from the database.
5
1349
by: darrel | last post by:
I'm new to ASP in general. Have been doing a bunch of stuff using classic ASP and a bit of stuff with ASP.NET (all with VBscript). The .NET stuff i've been doing has been fairly simple...generating a report from an Access table. The Datagrid along with some TemplateColumns seemed to work well for that. I'm not needing to now pull data from our Homemade CMS database to present on our public site.
1
4338
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls):
1
1810
by: angus | last post by:
Dear All, I am using VB.net It is found that the <asp:EditCommandColumn/> wouldn't fired an event for OnEditCommand If pushbutton has been used: that is:
0
938
by: Maziar Aflatoun | last post by:
Hi everyone, Does anyone know how I can add a CSS (Ex. button1 ) to the following Edit button is ASP .NET? <asp:EditCommandColumn ButtonType="PushButton" EditText="Edit" CancelText="Edit" UpdateText="Update"></asp:EditCommandColumn> I want to change the way my buttons look.
5
1943
by: Eric Caron | last post by:
Hi everyone, I have a web form that asks the user what languages he speaks and what his skill level is. I used a DataGrid control bound to a table that contains the languages and three template columns (beginner, intermediate, expert) that contain a radio button control. Now, only one skill level can be selected per language, so I tried to give the same name to the radio button control. When the page loads for the first time,...
1
1279
by: Dan | last post by:
Hi all, I have a question about datagrid: let's say I have a datagrid which shows the categories for some items; each category has an ID field and a description. I use an ASP.NET page with a datagrid bound to this table to show, edit or delete any row in this table. I have made a template of the edit/cancel column to be able to check for invalid values (e.g. an empty or duplicate category), using validators referring to the edit control of...
6
3345
by: Scott McDaniel | last post by:
I'm using Visual Studio 2005 with the .NET 2.0.50727 framework, and we're using the standard Datagrid control bound to a SQL Server. We have two groups of users - "full edit" users, and "view only" users. We would like to disable the EditCommandColumn of our Datagrid (named dgCertificates) for viewonly users. The intent is that viewonly would, obviously, only be able to view data and not maniupulate it in any way. I've tried the...
0
1317
by: slemen | last post by:
Hi, The asp:EditCommandColumn template does not fire the _edit sutboutine when the edit command column buttons are clicked. I get a Page Cannot Be Displayed page error instead. My (ASP 1.1) datagrid is defined in the HTML and the HTML <columns> has one defined template column and it is an asp:EditCommandColumn (with edit buttons). The datagrid's other columns are added at runtime by using the technique documented in the MSDN article:
0
9345
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
10115
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...
1
7332
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
6609
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
5229
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...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
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
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
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.