robduke
asked on
Exposing the EditItemIndex property of a DataGrid
Hello,
This is my first time asking a question here so please bear with me.
I have an editable DataGrid that is populated from an XML document. I have successfully written the code to Create Update and Delete rows to the grid.
The first column is an image. The xml document contains only the file name of that image, the url is appended at runtime through an AppSettings key.
My dilemma is this ... I need the user to be able to change the picture within the DataGrid as well. In edit mode it just lists the image file name. What i have done is I have made the image column read only and turned the actual photo within the grid into an asp:ImageButton. When the user clicks the image it hides the DataGrid and reveals an asp:panel containing the input file browser for uploading the new photo. The problem is I havent been able to successfully get the item index of the row from which the picture was selected. I cant seem to expose the EditItemIndex property of the the Datagrid within the method called by the onClick event in the asp:ImageButton.. I need this so i can write the photo information back to the proper record in the xml document.
I have done a lot of minor programming in the past but I am new to C# and this is a step farther than I have gone in the past. I am open to any and all suggestions.
Robert
This is my first time asking a question here so please bear with me.
I have an editable DataGrid that is populated from an XML document. I have successfully written the code to Create Update and Delete rows to the grid.
The first column is an image. The xml document contains only the file name of that image, the url is appended at runtime through an AppSettings key.
My dilemma is this ... I need the user to be able to change the picture within the DataGrid as well. In edit mode it just lists the image file name. What i have done is I have made the image column read only and turned the actual photo within the grid into an asp:ImageButton. When the user clicks the image it hides the DataGrid and reveals an asp:panel containing the input file browser for uploading the new photo. The problem is I havent been able to successfully get the item index of the row from which the picture was selected. I cant seem to expose the EditItemIndex property of the the Datagrid within the method called by the onClick event in the asp:ImageButton.. I need this so i can write the photo information back to the proper record in the xml document.
I have done a lot of minor programming in the past but I am new to C# and this is a step farther than I have gone in the past. I am open to any and all suggestions.
Robert
<datagridname>.row is the index
ASKER
I could be wrong but, I do not see a row property for DataGrid. Intellisense doesnt present it as an option either.
What im looking for is ... Can i get the row index of a Datagrid outside of edit mode.
What im looking for is ... Can i get the row index of a Datagrid outside of edit mode.
ASKER
I figured it out! :)
Technically i didnt realize that i could use an <asp:imageButton> within the <editTemaplate> of a datagrid. When I did this it allowed me to call the e.item.itemIndex property of the DataGridCommandEventArgs thus exposing the needed index.
Thanks
Robert
Technically i didnt realize that i could use an <asp:imageButton> within the <editTemaplate> of a datagrid. When I did this it allowed me to call the e.item.itemIndex property of the DataGridCommandEventArgs thus exposing the needed index.
Thanks
Robert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.