betul Posted August 10, 2007 Share Posted August 10, 2007 Hello,I have a grid with custom columns Name, Address, and a select field (link button). In DB table fields are ; ID, Name, Address and Image. I have created an image field to show a different image for each record when it is selected. The code in grid_SelectedIndexChanged is ; int selectedRowIndex; selectedRowIndex = grid.SelectedIndex; GridViewRow row = grid.Rows[selectedRowIndex]; string image = row.Cells[2].Text; branchMap.ImageUrl = "~/images/" + image ; However it doesn't work if I dont put Image field in the grid. I don't want to show this field because it is useless (to show something like record1.jpg in the grid.) Is there any simple way to do that without writing a new DB connection? Thanks. Link to comment Share on other sites More sharing options...
aspnetguy Posted August 10, 2007 Share Posted August 10, 2007 you still need to add that field to the gridview but you can hide it from view. Take a look herehttp://aspalliance.com/950 Link to comment Share on other sites More sharing options...
betul Posted August 10, 2007 Author Share Posted August 10, 2007 Great! Thank you. Just needed to convert it C# as; protected void grid_OnRowCreated(object sender,GridViewRowEventArgs e) { e.Row.Cells[2].Visible = false; } Link to comment Share on other sites More sharing options...
aspnetguy Posted August 10, 2007 Share Posted August 10, 2007 glad it worked for you. I know how you feel I don;t like VB syntax as much as C# Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.