I'm working on a gridview and got a little problem with the built in edit button.
the gridview got 3 columns title, artist, genre and when editing the genre a ddl shows.
in my grv_update event
protected void grv_Update(object sender, GridViewUpdateEventArgs e)
{
//get old and new values
var oldArtistName = e.OldValues["Artist"].ToString();
var oldTitle = e.OldValues["Title"].ToString();
var oldGenre = e.OldValues["Genre"].ToString();
int songId = Convert.ToInt16(e.Keys["ID"]);
var newArtistName = e.NewValues["Artist"].ToString().Trim();
var newTitle = e.NewValues["Title"].ToString().Trim();
var newGenre = e.NewValues["Genre"].ToString();
}
I'm able to retrieve the old and new values of the edited line.
My Problem is if i want to store the changes in my database i need the genreId instead of the genre(name). So is there anyway to retrieve the genreId from my sqldatasource without having to connect to the db?
my select command looks like this:
select tblSong.ID ,Title, Artist, Genre from tblSong JOIN tblArtist on ArtistId = tblArtist.ID
JOIN tblGenre on GenreId = tblGenre.ID;
thanks for your help!