|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Disable Dropdown list in GridView(Edit Mode)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. 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. 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. 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. 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.
Error Rendering Control - ButtonSearch An unhandled exception has occurred. There was an error pars
Label Style Result not expected with user control - any ideas why/ Problem adding attributes to DataListItem.. OnDayRender won't render Role based security Tabbed control for ASP.NET pages Trouble with radio button list in Asp.net 1.1 Templated User Control & intellisense Find the source of an event |
|||||||||||||||||||||||