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

Datagrid asp:EditCommandColumn with Creating Templates in a progra

Hi,

The DataGrid aps:EditCommandColumn when used with column templates created
programmatically 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" AutoGenerateColumns="False"
AllowSorting="True"
Font-Names="Verdana"AlternatingItemStyle-BackColor="Gainsboro"
OnItemDataBound="MyDataGrid_ItemBound" ShowFooter="True"
OnSortCommand="MyDataGrid_SortCommand" OnEditCommand="MyDataGrid_Edit"
OnCancelCommand="MyDataGrid_Cancel"
onDeleteCommand="MyDataGrid_DeleteCommand"
OnUpdateCommand="MyDataGrid_Update" BorderWidth="1px"
Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
BorderColor="Black" CellPadding="3"Height="441px">
<HeaderStyle BackColor="#AAAADD" Wrap="False"></HeaderStyle>

<Columns>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Ok"
HeaderText="Edit Info" CancelText="Cancel" EditText="Edit">
<HeaderStyle Wrap="False" HorizontalAlign="Center" Width="50px"></HeaderStyle>
<ItemStyle Wrap="False" Width="50px"></ItemStyle>
</asp:EditCommandColumn>
</Columns>
</ASP:DATAGRID>

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

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

3)
Public Class DynamicDataGridTemplate
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(ByVal container As Control) _
Implements ITemplate.InstantiateIn

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

chkBox1.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox1)
If columnName.StartsWith("Acad") Then
chkBox2.Checked = True
Else
chkBox2.Checked = False
End If
chkBox2.Text = "Desc"
chkBox2.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox2)
Else
chkBox1.Text = "Asc"
chkBox1.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox1)
chkBox2.Text = "Desc"
chkBox2.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox2)
End If
End If
Case ListItemType.Item
lc.Text = "Item " & columnName
container.Controls.Add(lc)
Case ListItemType.EditItem
Dim tb As New TextBox
tb.Text = ""
container.Controls.Add(tb)
Case ListItemType.Footer
lc.Text = "<I>Footer</I>"
container.Controls.Add(lc)
End Select
End Sub
End Class

Jun 19 '06 #1
0 1212

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

Similar topics

0
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...
5
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...
1
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...
1
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
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"...
5
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...
1
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...
6
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...
0
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)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.