[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Gridview Coding issue  - EditItemTemplate

Posted on 2013-01-24
12
Medium Priority
?
368 Views
Last Modified: 2013-01-27
I have a gridview which displays data regarding tasks assigned to various people, within the grid I have setup a template within the 'Resource' field, which reads a list of Resources from another table and then lets me choose a resource to update the table which is displaying the data in the gridview.
What I would like to do is, when a resource is selected from the drop down, I want an event to fire that will send an email to that resource, I have the code for sending the email and also the code for selecting the email address, my issue is how can I bind this to this type of control ? Or is there a better way to do this ?
0
Comment
Question by:ndr-itsolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 38816671
Do you want to send an email as soon as the resource is selected in the dropdown or only when user Submit the update changes?
0
 

Author Comment

by:ndr-itsolutions
ID: 38816730
When the user submits the updated changes.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 38816738
You can do that in the RowCommand or RowUpdate Event handler.
It will be a single row update right or you have multiple row updates at a single time?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ndr-itsolutions
ID: 38816758
Yes, a single row.

Any example code ?
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 38816822
It would be something like this:

protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
        string resource = e.NewValues[1].ToString(); //1 is the index for your resource column
        //the row was updated and you can send your email here.
}
0
 
LVL 10

Expert Comment

by:Monica P
ID: 38817617
http://www.codeproject.com/Questions/163877/Row-updating-event-in-gridview-ASP-NET

http://stackoverflow.com/questions/987980/getting-a-selected-value-from-the-drop-down-list-inside-a-gridview-on-update

try to find the control under RowUpdated event


try something like this

protected void gv_UpdateRow(string arg)
{
    int currentIndex = gv.EditIndex;
    gv.EditIndex = -1;

    GridViewRow currentRow = gv.Rows[currentIndex];

    try
    {
      string value2 = ((DropDownList)currentRow.FindControl("ddlValueTwo")).SelectedItem.ToString();
//Place your email code here and test 
    }
    catch
    {
        Response.Write("error");
    }


    BindGridView(); 
}

Open in new window


GEt DDL selected value in gridview

http://www.dotnetfunda.com/codes/code3389-how-to-get-dropdownlist-selected-value-in-inside-gridview-in-aspnet.aspx
http://stackoverflow.com/questions/5000489/how-to-edit-and-update-row-values-in-grid-view
0
 

Author Comment

by:ndr-itsolutions
ID: 38817739
Sorry should have said, I'm using vb.net
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38817980
Here, use this

http://converter.telerik.com/
Protected Sub gv_UpdateRow(arg As String)
	Dim currentIndex As Integer = gv.EditIndex
	gv.EditIndex = -1

	Dim currentRow As GridViewRow = gv.Rows(currentIndex)

	Try
			'Place your email code here and test 
		Dim value2 As String = DirectCast(currentRow.FindControl("ddlValueTwo"), DropDownList).SelectedItem.ToString()
	Catch
		Response.Write("error")
	End Try


	BindGridView()
End Sub

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================

Open in new window

0
 

Author Comment

by:ndr-itsolutions
ID: 38818247
So where would I insert this code ?
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 38820712
Can you tell what code you are trying to use? Did you follow the links posted?
The basic idea is handle your GridView's RowUpdated event.
0
 

Author Comment

by:ndr-itsolutions
ID: 38823745
I'm looking to use the first suggestion

 Dim resource As String = e.NewValues(1).ToString()
        '1 is the index for your resource column
        'the row was updated and you can send your email here.

I've placed it in the code behind of the web form that contains the gridview.
0
 

Author Closing Comment

by:ndr-itsolutions
ID: 38824997
This worked a treat after I worked out that I had not added my sub routine to the gridview.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question