473,734 Members | 2,788 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 1240

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

Similar topics

0
1021
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
1347
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
4334
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
1807
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
936
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
1942
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
1278
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
3344
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
1309
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
8946
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
8776
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
9310
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
8186
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, 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...
1
6735
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
6031
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.