Home All Groups Group Topic Archive Search About

Disable Dropdown list in GridView(Edit Mode)

Author
13 Dec 2005 5:29 PM
Houston Lucifer
Hi all, i have three column in GridView which in the edit mode are dropdown
lists. Based on the role, when the user clicks on the 'Edit' Button i need to
disable any two of those columns. How can i do this. Can i generate the 'Edit
Item Template' at runtime? Is there any easy way?

Thanks for the help.

Author
13 Dec 2005 5:46 PM
Phillip Williams
Hi Houston,

You can use the RowCreated event like this:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowState == DataControlRowState.Edit)
    {
        DropDownList ddl1 = (DropDownList)e.Row.FindControl("dropdownlist1");
        //use the reference to the dropdownlist to enable or disable it
based on the roles
        if (Context.User.IsInRole ("Manager") )
        {
            ddl1.Enabled = false;
        }
    }
}
Show quoteHide quote
"Houston Lucifer" wrote:

> Hi all, i have three column in GridView which in the edit mode are dropdown
> lists. Based on the role, when the user clicks on the 'Edit' Button i need to
> disable any two of those columns. How can i do this. Can i generate the 'Edit
> Item Template' at runtime? Is there any easy way?
>
> Thanks for the help.
Author
13 Dec 2005 7:30 PM
Houston Lucifer
Thanks i will try this.

Show quoteHide quote
"Phillip Williams" wrote:

> Hi Houston,
>
> You can use the RowCreated event like this:
>
> protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
> {
>     if (e.Row.RowState == DataControlRowState.Edit)
>     {
>         DropDownList ddl1 = (DropDownList)e.Row.FindControl("dropdownlist1");
>         //use the reference to the dropdownlist to enable or disable it
> based on the roles
>         if (Context.User.IsInRole ("Manager") )
>         {
>             ddl1.Enabled = false;
>         }
>     }
> }
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Houston Lucifer" wrote:
>
> > Hi all, i have three column in GridView which in the edit mode are dropdown
> > lists. Based on the role, when the user clicks on the 'Edit' Button i need to
> > disable any two of those columns. How can i do this. Can i generate the 'Edit
> > Item Template' at runtime? Is there any easy way?
> >
> > Thanks for the help.
Author
13 Dec 2005 9:57 PM
Houston Lucifer
Thanks. This did it. I appreciate it.

Show quoteHide quote
"Phillip Williams" wrote:

> Hi Houston,
>
> You can use the RowCreated event like this:
>
> protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
> {
>     if (e.Row.RowState == DataControlRowState.Edit)
>     {
>         DropDownList ddl1 = (DropDownList)e.Row.FindControl("dropdownlist1");
>         //use the reference to the dropdownlist to enable or disable it
> based on the roles
>         if (Context.User.IsInRole ("Manager") )
>         {
>             ddl1.Enabled = false;
>         }
>     }
> }
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Houston Lucifer" wrote:
>
> > Hi all, i have three column in GridView which in the edit mode are dropdown
> > lists. Based on the role, when the user clicks on the 'Edit' Button i need to
> > disable any two of those columns. How can i do this. Can i generate the 'Edit
> > Item Template' at runtime? Is there any easy way?
> >
> > Thanks for the help.
Author
14 Dec 2005 4:06 PM
Phillip Williams
You are welcome.
Show quoteHide quote
"Houston Lucifer" wrote:

> Thanks. This did it. I appreciate it.
>
> "Phillip Williams" wrote:
>
> > Hi Houston,
> >
> > You can use the RowCreated event like this:
> >
> > protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
> > {
> >     if (e.Row.RowState == DataControlRowState.Edit)
> >     {
> >         DropDownList ddl1 = (DropDownList)e.Row.FindControl("dropdownlist1");
> >         //use the reference to the dropdownlist to enable or disable it
> > based on the roles
> >         if (Context.User.IsInRole ("Manager") )
> >         {
> >             ddl1.Enabled = false;
> >         }
> >     }
> > }
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Houston Lucifer" wrote:
> >
> > > Hi all, i have three column in GridView which in the edit mode are dropdown
> > > lists. Based on the role, when the user clicks on the 'Edit' Button i need to
> > > disable any two of those columns. How can i do this. Can i generate the 'Edit
> > > Item Template' at runtime? Is there any easy way?
> > >
> > > Thanks for the help.