Hi,
I have a Data List control which displays events. I have 2 functionalities in data list. They are Edit,Copy.
When I click EDIT button, and edit item template is loaded which has an UPDATE button to update the data.
When I click the COPY button, the same edit item template is loaded, which should have a SAVE button (to save the event as a new event).
The problem here is if I click on EDIT I have to display UPDATE Button, If I click on Copy I have to display SAVE button.
How do I know which button is clicked in Item_DataBound Event of Data list.
Can any one please help me in this issue.
Thank you, I appreciate your time.
Naresh
Loading
Jignesh TrivediPosted Jan 25, 2012, 1:12 AM
EDIT, Copy command define in Item template.
and for command you can put link button and link button (in item templte) has one property CommandName you can assing it.
void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
var commandName = e.CommandName;
}
put switch case or if else and write your code
hope this help.
NareshPosted Jan 24, 2012, 3:18 PM
Thank you for the reply.
I am able to capture the command name in ItemCommand, but I want to find out the name of the control in Data List which triggered the post back (whether it is EDIT or COPY) in the Event_ItemDataBound
method.
Though, I found a solution for this, on page load if it is a postback am using "Request.Params.Get("_EVENTTARGET")" to get the control name and assigning it to a property which I declared initially.
In the _ItemDataBound, I am retrieving the property. I am not sure this is a correct way to do it, but this is working.
Please let me know, if their is any other way to do this.
Thank you,
Naresh
Jignesh TrivediPosted Jan 23, 2012, 11:08 PM
use item command for capture event.
please refer
http://www.codeproject.com/Articles/14293/Gridview-Inside-a-GridView-in-ASP-NET-2-0
http://community.devexpress.com/forums/p/69958/238326.aspx
hope this help.