Hey !!
I m havin a gridview and i used there :
<asp:CommandField ButtonType="Image" UpdateImageUrl="~/Images/Update.gif"
CancelImageUrl="~/Images/Cancel.gif" DeleteImageUrl="~/Images/Delete.gif"
EditImageUrl="~/Images/Edit.gif" SelectImageUrl="~/Images/Show.gif"
ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="true" >
the problem in here dat i want to enable edit and delete button depending on
user's role.
i jus done with delete button as:
ImageButton deleteButton = (ImageButton)e.Row.Cells[3].Controls[2];
if (User.IsInRole("Tracker"))
{
deleteButton.Enabled = false;
deleteButton.ImageUrl = "../../images/Delete_Disabled.gif";
deleteButton.ToolTip = "Access is denied";
}
but while working with edit button; as same, an exception occured with
Unable to cast object of type 'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.ImageButton'
Please suggest some solution of it; thnx
Regards;
Aisha!!
--- On Sun, 12/21/08, Juan M. Oviedo <[email protected]> wrote:
From: Juan M. Oviedo <[email protected]>
Subject: [DotNetDevelopment] Re: GridView question - I'd like to solve this
EVENTually...?! (heheh... heh...)
To: [email protected]
Date: Sunday, December 21, 2008, 9:01 PM
#yiv200457164 .hmmessage P
{
margin:0px;padding:0px;}
#yiv200457164 {
font-size:10pt;font-family:Verdana;}
Seems like you have:
ShowButton("btnUpdate", (!isEditMode));
ShowButton("btnDelete", (!isEditMode));
ShowButton("btnSave", isEditMode);
ShowButton("btnCancel", isEditMode);
instead of!:
ShowButton("btnUpdateBlend", (!isEditMode));
ShowButton("btnDeleteBlend", (!isEditMode));
ShowButton("btnSaveBlend", isEditMode);
ShowButton("btnCancelBlend", isEditMode);
It happens....good luck.
Juan M. Oviedo
> Date: Sun, 21 Dec 2008 19:08:57 -0800
> Subject: [DotNetDevelopment] GridView question - I'd like to solve this
> EVENTually...?! (heheh... heh...)
> From: [email protected]
> To: [email protected]
>
>
> Hello, could someone please help me with the VS 2008 website project
> I've linked below:
>
> http://rapidshare.com/files/175651724/WebApplication1.rar.html
>
> The RAR file's password is "darthcontinent".
>
> Basically, this is a website project which uses a GridView control to
> edit a couple of rows of data. The rows will initially be blank, be
> edited by the user, and eventually saved to a table. In the meantime,
> the user is given the option to Edit a particular row (you can ignore
> the Delete button for purposes of my question).
>
> I can run the project and choose the Edit button for a row of data,
> and the fields in this row become editable, which is super. However,
> the problem I'm having trouble wrapping my head around is that after
> the fields become editable, the Edit button should no longer say Edit,
> but instead should say Update (i.e. btnEdit is to be hidden, and
> btnUpdate becomes visible).
>
> If you attempt this process, you'll notice that you get an Object
> reference not set error when the code tries to act on a reference to
> the (at that point nonexistent) btnUpdate.
>
> Could someone please help me?! In debugging this I'm now quite
> confused about which events aren't firing or being handled in the
> right sequence to make this happen. If for any reason you can't
> download the file from the link above, please email me at
> DarthContinent (@) gmail.com and I can send it to you directly. Or if
> preferable I can post the code here, please let me know.
>
> Thanks in advance for any help!!
>
Send e-mail faster without improving your typing skills. Get your Hotmail®
account.