By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,301 Members | 3,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,301 IT Pros & Developers. It's quick & easy.

Help on ImageButton ??

P: n/a
Dear all,

I gave a datagrid object wich has a template column define as follow :

<asp:TemplateColumn HeaderText="Evt">
<ItemTemplate>
<asp:ImageButton id="ImageButton2" ImageAlign=Middle runat="server"
ImageUrl="event.gif" CommandName="ShowEvent" CommandArgument
='<%#DataBinder.Eval(Container,"DataItem.ID")%>' >
</asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>

When I click on my imagebutton I would like to trig the Command event of the
image button ?

How can I do that because phisycally the imagebutton is not seen in code as
it belongs to template

Or may be it is not working with it ?

Thnaks for your help
regards
serge
Jan 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In a similar scenario I explicitly set the server click event (see below):

<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton Runat="server" Text="Submit"
OnClick="SubmitProfile_Click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>

Then in the code I redirected the click event back to the ItemCommand event
for the grid:

Protected Sub SubmitProfile_Click(ByVal sender As Object, ByVal e As
EventArgs)
Dim btn As LinkButton = CType(sender, LinkButton)

'NOTE: I set the CommandName of the LinkButton to the ItemIndex for
where it exists in the ItemDataBound event for the grid
Me.myGrid_ItemCommand(Me, _
New
DataGridCommandEventArgs(myGrid.Items(Convert.ToIn t32(btn.CommandName)), _
myGrid, _
New CommandEventArgs("Select", Nothing)))
End Sub

HTH,

Matt Dinovo

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
Dear all,

I gave a datagrid object wich has a template column define as follow :

<asp:TemplateColumn HeaderText="Evt">
<ItemTemplate>
<asp:ImageButton id="ImageButton2" ImageAlign=Middle runat="server"
ImageUrl="event.gif" CommandName="ShowEvent" CommandArgument
='<%#DataBinder.Eval(Container,"DataItem.ID")%>' >
</asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>

When I click on my imagebutton I would like to trig the Command event of
the
image button ?

How can I do that because phisycally the imagebutton is not seen in code
as
it belongs to template

Or may be it is not working with it ?

Thnaks for your help
regards
serge

Jan 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.