How to change src of Edit button inside EditCommandColumn

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to change the "scr" like src='images/Edit.ICO' to
src='images/XYZ.ICO' dynamically based on some condition.

My EditCommandColumn:
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="<img alt='Save'
src='images/Save.ICO' height=20 width=20 border=0>" CancelText="<img
alt='Cancel' src='images/Cancel.ICO' height=20 width=20 border=0>"
EditText="<img alt='Save' src='images/Edit.ICO' height=20 width=20 border=0>"
ItemStyle-HorizontalAlign="Center"
ItemStyle-VerticalAlign="Middle"></asp:EditCommandColumn>

How can I do this?
Could you please give me some idea.
 
Hello Sourav,

Create flag variable that will be marked when your condition has happened.
Afterwars, in DataGrid1_ItemCreated/DataGrid1_ItemDataBound change property
of your button. First event fired when grid is in the start of grid creating
and the second one fires at the bottom of the chain of events that occur
when the grid layout is created



SG> I want to change the "scr" like src='images/Edit.ICO' to
SG> src='images/XYZ.ICO' dynamically based on some condition.
SG>
SG> My EditCommandColumn:
SG> <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="<img
SG> alt='Save'
SG> src='images/Save.ICO' height=20 width=20 border=0>"
SG> CancelText="<img
SG> alt='Cancel' src='images/Cancel.ICO' height=20 width=20 border=0>"
SG> EditText="<img alt='Save' src='images/Edit.ICO' height=20 width=20
SG> border=0>"
SG> ItemStyle-HorizontalAlign="Center"
SG> ItemStyle-VerticalAlign="Middle"></asp:EditCommandColumn>
SG> How can I do this? Could you please give me some idea.
SG>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Hi Michael,

Thanks for your reply.
Could you please give me a bit detail regarding this issue. I need to know
an example for accessing the EditText property of EditCommandColumn.

thanks
sourav.
 
Hello Sourav,

In the code below I've added JS dialog to the the update button Click

private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
// Add confirm javascript dialog to the update button in the selected row
if (e.Item.ItemType == ListItemType.EditItem)
{
// Get update column
LinkButton lnkUpdate = (LinkButton)((TableCell)e.Item.Controls[0]).Controls[0];
if (lnkUpdate != null && lnkUpdate.CommandName == "Update")
{
// Call confirm dialog with onclick event handler
lnkUpdate.Attributes["onclick"] = "return confirm('Are you sure you
want to commit your changes?');";
}
}
}

SG> Hi Michael,
SG>
SG> Thanks for your reply.
SG> Could you please give me a bit detail regarding this issue. I need
SG> to know
SG> an example for accessing the EditText property of EditCommandColumn.
SG> thanks sourav.
SG>
SG> "Michael Nemtsev" wrote:
SG>---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Hi Michael,

thanks for your help. I would definitely try it out.

regards
sourav.


Michael Nemtsev said:
Hello Sourav,

In the code below I've added JS dialog to the the update button Click

private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
// Add confirm javascript dialog to the update button in the selected row
if (e.Item.ItemType == ListItemType.EditItem)
{
// Get update column
LinkButton lnkUpdate = (LinkButton)((TableCell)e.Item.Controls[0]).Controls[0];
if (lnkUpdate != null && lnkUpdate.CommandName == "Update")
{
// Call confirm dialog with onclick event handler
lnkUpdate.Attributes["onclick"] = "return confirm('Are you sure you
want to commit your changes?');";
}
}
}

SG> Hi Michael,
SG>
SG> Thanks for your reply.
SG> Could you please give me a bit detail regarding this issue. I need
SG> to know
SG> an example for accessing the EditText property of EditCommandColumn.
SG> thanks sourav.
SG>
SG> "Michael Nemtsev" wrote:
SG>---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Back
Top