473,385 Members | 1,553 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,385 software developers and data experts.

How to change src of Edit button inside EditCommandColumn


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
4 1963
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Bishop | last post by:
I have a form with a search text box and a grid that displays the results. Within the grid, I have edit command links set up to response.redirect to another page that puts the DataKey value in the...
0
by: Ante Perkovic | last post by:
Hi, I have this piece of code: <asp:datagrid id="dgRezervirano" runat="server" CssClass="rezervacije" AutoGenerateColumns="false" DataKeyField="id" Width="650px"> .... <asp:EditCommandColumn...
4
by: DC | last post by:
Newbie's question about .NET datagrid If I use: <asp:EditCommandColumn></asp:EditCommandColumn> When I edit a row, it will automatically show Update and Cancel Link. But when I use:...
0
by: Steve Kallal | last post by:
I have a DataGrid with an EditCommandColumn column set to a type of PushButton. I want to set set CssClass on these buttons and cannot without using code-behind code on the ItemDataBound event. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.