Is there a way to make a column that has an image with a hyperlink on it?
Cause I know how to make a hyperlink column, and a image column, but not how
to mix it both...
Tnx!
For a callback I use a ButtonColumn, set following things:
Text:
<img src="Resources/images/Delete.gif?" width="18" height="18"
border="0" Alt="Delete this Trade">
Command:
cmdDelete
Button Type:
Link Button
For a link (it's actually with javascript, but you get the idea) I use
a plain BoundColumn:
Data formating expression:
<A HREF=javascript:onClick=OpenNTMWindow({0});><img
src="Resources/images/XmlSign.gif?" width="18" height="18" border="0"
Alt="Show NTM Message"></a>
Data Field:
Whatever column from the db you wanna have in the {0} placeholder
above.
Hope that helps. You can build some pretty powerfull stuff this way.
Cheers
Remy Blaettler
www.collaboral.com
Tnx!
"Remy" <rblae...@hotmail.com> escribió en el mensaje
news:1133966469....@g43g2000cwa.googlegroups.com...
I used the javascript just fine. Now I was trying to use the "real" button,
but I came across a problem. The button is in a gridview inside another
gridview. How can I now wich record the user "selected" pressing the button?
"Remy" <rblae...@hotmail.com> wrote in message
news:1133966469....@g43g2000cwa.googlegroups.com...
private void dgErrorMessages_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
OdbcConnection execConn = null;
int rowID;
if (e.CommandName == "cmdResend")
{
//ItemIndex is only available if it is a command from a
row, but we also get the Page
//command in here
rowID = Convert.ToInt32(e.Item.Cells[3].Text);
log.Info("cmdResend - RowID = " + rowID);
try
{
execConn =
DatabaseUtils.OpenDatabaseConnection("Executive");
lbResult.Text = coreLogic.ResendNtmMessage(rowID,
coreLogic.GetStartDate(cldrStart), coreLogic.GetEndDate(cldrEnd),
execConn);
FillAndBindGrid(execConn);
}
finally
{
if(execConn != null) execConn.Close();
}
}
else if (e.CommandName == "cmdDelete")
{
//ItemIndex is only available if it is a command from a
row, but we also get the Page
//command in here
rowID = Convert.ToInt32(e.Item.Cells[3].Text);
log.Info("cmdDelete - RowID = " + rowID);
try
{
execConn =
DatabaseUtils.OpenDatabaseConnection("Executive");
lbResult.Text = coreLogic.DeleteNtmMessage(rowID,
execConn);
FillAndBindGrid(execConn);
}
finally
{
if(execConn != null) execConn.Close();
}
}
}
dgErrorMessages is the name of the grid. ItemCommand is the event
handler for all the commands that are sent via the columns. The command
name is put into the CommandName field in the ButtonColumn
configuration.
But the core is
e.Item.Cells[3]
which is how I get the ID for this column. The ID is in my 3rd column
(or in the 4th, not sure if it zero based anymore).
It's not very nice to hardcode the 3 into the code, but...
Hope that gives you a hint
Cheers
Remy Blaettler
www.collaboral.com