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

Need help with a custom control and a datagrid

Hi,
I had created a web custom control to ask for user' confirmation on deleting
and others process. I put the control in a vb file.
The control is really simple: only an image button and a hidden panel to
show a wait message....
The control has a PreRender (with a RegsiterClientScriptBlock) event and a
Render event (that writes the control)
I put the control on a datagrid.
The control asks confirmation fine and I'm able to retrieve (in
ItemDataBound, por example) the control, to make it enabled or not, to show
it or not.
The problem is that the control does not launch the ItemCommand event in the
datagrid. So I'm not able to process the request after the user'
confirmation.
This is what I have done so far:

'vb: GridControls
Namespace GridControls
public class ctrConfirmButton
public ConfirmMessage as string =""
public CommandName as string = ""
public Imagen as string = ""
public ToolTip as string = ""
public Enabled as boolean = False

protected overrides sub OnPreRender(ByVal e As System.EventArgs)
dim sScript as string = "" _
"<script language='javascript'>" & _
"function __" & me.id & "_doConfirm() {" & _
"if (confirm('" & ConfirmMessage & "')) {return true;}
return false; }" & _
"</script>"

page.RegsiterClientScriptBlock("__" & me.id & "_doConfirm",
sScript)
myBase.OnPreRender(e)
end sub

protected overrides sub Render(ByVal writer as
System.Web.UI.HtmlTextWriter)
dim sDisabled as string = "disabled='disabled' "

if Enabled then sDisabled = ""

writer.write("<input type='image' id= '" & me.id & "_" &
CommandName & "' title= '" & ToolTip & "' src='" & Imagen & "' alt=''
border='0' " _
sDisabled & _
"onclick='return __" & me.id & "_doConfirm();' >"
end sub
end class
end namespace

'Page
<%@ Register TagPrefix= "CtrlsGrid" NameSpace="ControlsProj:GridControls"
Assably="ControlsProj" %>

'.....

<asp:templatecolumn>
<CtrlsGrid:ctrConfirmButton runat="server"
id="MyID"
CommandName="Delete"
ConfirmMessage="The message"
Image="Iconos/..."
ToolTip="The Tooltip"
Enabled="True"

</CtrlsGrid:ctrConfirmButton>
</asp:templatecolumn>

'Codebehind
private sub MyItemDataBound(ByVal Sender as object, e as
system.web.ui.webcontrols.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
select case e.item.ItemType
case ListItemType.Item
dim myControl as ControlsProj.GridControls.ctrConfirmButton =
ctype(e.item.FindControl("MyID"),
ControlsProj.GridControls.ctrConfirmButton)
if not myControl is nothing then myControl .Enabled = True
case ListItemType.AlternatingiItem
dim myControl as ControlsProj.GridControls.ctrConfirmButton =
ctype(e.item.FindControl("MyID"),
ControlsProj.GridControls.ctrConfirmButton)
if not myControl is nothing then myControl .Enabled = False
end select
end sub

private sub MyItemCommand(ByVal Sender as object, e as
system.web.ui.webcontrols.DataGridCommanEventArgs) handles
DataGrid1.ItemCommad
me.DataGrid1.DataBind()
end sub
The last sub is not getting launch. There is something that I'm missing and
I cannot make a connection between the datagrid and the control.

THX, in advance
Luis Alonso






Nov 21 '05 #1
0 1104

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

Similar topics

0
by: Julien | last post by:
Hi, I created a custom server control, compiled as a DLL (it's a composite server control). In my apsx page, I use something like : <MyAssembly:MyObject properties> <asp:datagrid />...
1
by: Job Lot | last post by:
I have created a custom DataGrid control which implements a custom property HighlightRow of type Boolean. I have another custom DataGridTextBoxColumn class, which Overrides the Paint method in...
4
by: Carl Fenley | last post by:
I believe I have almost successfully created a custom datagrid control. The new class builds without error. I have added it as reference to the main Windows Application project. It appears on...
0
by: paul.phillips | last post by:
Hi, I am a problem: I have a custom control called DataView that holds a DataGrid object. The DataGrid has an event attached (PageIndexChanged) now the problem is that the event is not being...
1
by: philipl | last post by:
hi, i have a datagrid which display custom controls when user clicks edit, changing data. I am using customvalidator to validate this control. I can get validation of user input to work no...
0
by: Earl Teigrob | last post by:
I have created a templated custom control that simply creates a spacing table around other objects. This control works fine for most uses but when I add it inside the ItemTemplate of a DataGrid...
1
by: Glenn Owens | last post by:
I have a Web DataGrid into which I've added a templatecolumn. Into the templatecolumn I've placed a progressbar custom control (which provides its rendering by overriding the Render method of the...
2
by: tperri | last post by:
I've got a page with a couple ascx files on it. One od the controls displays a user's picture, the other contains a datagrid where a user can upload more pictures, change their default picture,...
1
by: Sam Samnah | last post by:
Hi Everyone. It has been a long time since my last post. Nevertheless, I have built a custom server control that allows a user to edit text, bolding, italics strike though table insertion and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.