?
Solved

Gridview Coding issue  - EditItemTemplate

Posted on 2013-01-24
12
Medium Priority
?
366 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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