|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Disable ButtonColumn button control through codeHello,
Is there any way to disable a button control inside a ButtonColumn of a datagrid ? I could get the button by using syntax like grid.Items[rownum].cells[columnnum].controls[0] and set its enabled property to false (((Button)grid.Items[rownum].cells[columnnum].controls[0]).Enabled = false), but as soon as grid.DataBind() is executed after disabling, the button is enabled again. How can it be disabled and enabled as per logic requirements? -- Sameeksha, MCP (.NET) Hi,
you would do this in ItemDataBound event for the grid (which runs for every databound grid item when DataBind is called), when you could set it one by one (some buttons are enabled, some aren't which you could detect from data source). Is this what you are asking? -- Show quoteHide quoteTeemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsider ASP.NET Forum Moderator, AspAlliance Columnist http://blogs.aspadvice.com/joteke "Sameeksha" <Sameek***@discussions.microsoft.com> wrote in message news:34EA4AB6-1336-411D-AB21-CF50EF57A3C4@microsoft.com... > Hello, > > Is there any way to disable a button control inside a ButtonColumn of a > datagrid ? I could get the button by using syntax like > grid.Items[rownum].cells[columnnum].controls[0] and set its enabled > property > to false > (((Button)grid.Items[rownum].cells[columnnum].controls[0]).Enabled = > false), but as soon as grid.DataBind() is executed after disabling, the > button is enabled again. How can it be disabled and enabled as per logic > requirements? > > -- > Sameeksha, > MCP (.NET) The buttoncolumn which I want to enable and disable is not databound. What I
wish to do is enable the button ONLY WHEN the datagrid row is in edit mode, and disabled at all other times (that is after update of row is complete). So I'm not sure if ItemDataBound event will be useful. If I have to use ItemDataBound, how do I detect if the row is in edit mode or not? Show quoteHide quote "Teemu Keiski" wrote: > Hi, > > you would do this in ItemDataBound event for the grid (which runs for every > databound grid item when DataBind is called), when you could set it one by > one (some buttons are enabled, some aren't which you could detect from data > source). Is this what you are asking? > > -- > Teemu Keiski > MCP, Microsoft MVP (ASP.NET), AspInsider > ASP.NET Forum Moderator, AspAlliance Columnist > http://blogs.aspadvice.com/joteke > > > "Sameeksha" <Sameek***@discussions.microsoft.com> wrote in message > news:34EA4AB6-1336-411D-AB21-CF50EF57A3C4@microsoft.com... > > Hello, > > > > Is there any way to disable a button control inside a ButtonColumn of a > > datagrid ? I could get the button by using syntax like > > grid.Items[rownum].cells[columnnum].controls[0] and set its enabled > > property > > to false > > (((Button)grid.Items[rownum].cells[columnnum].controls[0]).Enabled = > > false), but as soon as grid.DataBind() is executed after disabling, the > > button is enabled again. How can it be disabled and enabled as per logic > > requirements? > > > > -- > > Sameeksha, > > MCP (.NET) > > > Hi,
I could achieve the enabling and disabling using ItemDataBound event as follows: I checked for the e.Item.ItemType property, and if it's EditItem, then I wrote code to enable the buttons, else I'm disabling them. Thanks for help Show quoteHide quote "Teemu Keiski" wrote: > Hi, > > you would do this in ItemDataBound event for the grid (which runs for every > databound grid item when DataBind is called), when you could set it one by > one (some buttons are enabled, some aren't which you could detect from data > source). Is this what you are asking? > > -- > Teemu Keiski > MCP, Microsoft MVP (ASP.NET), AspInsider > ASP.NET Forum Moderator, AspAlliance Columnist > http://blogs.aspadvice.com/joteke > > > "Sameeksha" <Sameek***@discussions.microsoft.com> wrote in message > news:34EA4AB6-1336-411D-AB21-CF50EF57A3C4@microsoft.com... > > Hello, > > > > Is there any way to disable a button control inside a ButtonColumn of a > > datagrid ? I could get the button by using syntax like > > grid.Items[rownum].cells[columnnum].controls[0] and set its enabled > > property > > to false > > (((Button)grid.Items[rownum].cells[columnnum].controls[0]).Enabled = > > false), but as soon as grid.DataBind() is executed after disabling, the > > button is enabled again. How can it be disabled and enabled as per logic > > requirements? > > > > -- > > Sameeksha, > > MCP (.NET) > > >
) expected erro when trying to create a popup
click on TreeNode Which event? Capturing event from other custom control within another custom control Problem programmatically creating tabstrip webcontrol dynamic control event not firing DataList inside a datalist. Free TreeView Controls ? Textbox interpreting html tags (like the label) RE: java script error on postback |
|||||||||||||||||||||||