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

How to change src of Edit button inside EditCommandColumn

P: n/a

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.
Mar 17 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 Nietzsche
Mar 17 '06 #2

P: n/a
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.

"Michael Nemtsev" wrote:
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 Nietzsche

Mar 18 '06 #3

P: n/a
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>
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 Nietzsche

---
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
Mar 18 '06 #4

P: n/a
Hi Michael,

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

regards
sourav.
"Michael Nemtsev" wrote:
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>
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 Nietzsche

---
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

Mar 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.