Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 25th, 2006, 09:19 PM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default enable/disable checkbox in data grid on edit

Hi Guys,

I have an urget problem pls help me.

I have a datagrid with a checkbox column and a dropdownlist column. Both are in Template columns and both are disabled( greyed out) in the begining .

and i have edititem command.

I wanted to make both checkbox and dropdown list editable when edit button is clicked .

I tried
e.Item.Cells[1].Enabled = true;

e.Item.Cells[1].FindControl("Active").Enabled = true;

But nothing seemed to work .


Plssssssss help me . Its very urgent


FYI

My html code is

<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
                                <asp:TemplateColumn HeaderText="Inactive">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="Active" Runat="server" Enabled=False Checked='<%# DataBinder.Eval(Container.DataItem, "Active")%>'>
                                        </asp:CheckBox>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:BoundColumn DataField="Description" ReadOnly="True" HeaderText="Product Line"></asp:BoundColumn>
                                <asp:BoundColumn DataField="ProductLinecode" ReadOnly="True" HeaderText="Product Line Code"></asp:BoundColumn>
                                <asp:TemplateColumn HeaderText="Fullfillment Extract">
                                    <ItemTemplate>
                                        <asp:DropDownList ID="DropdownListFullfilment" Enabled="False" Runat="server" Width="100px"></asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                        </asp:datagrid></td>


  #2 (permalink)  
Old October 28th, 2006, 01:18 AM
Authorized User
 
Join Date: Aug 2006
Location: Pune, Maharastra, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this

checkbox cb;
cb = (checkbox)(e.item.cells(1).control(0 or 1)
cb.enabled = true


all the best

  #3 (permalink)  
Old October 30th, 2006, 12:37 PM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hai,

 The answer to checkbox is u just find out the control in which cell it is present and type caste it to checkbox and assign it to checkbox string and from that string u can enable or disable the control according to ur requirement.
Ex:
  in itemdatagrid bound or some other event it depends upon ur req

 CheckBox cb=(checkbox)e.item.cells[cellno].findControl("checkboxid");

then
 if(cb.Checked==true)
{
 //some code
}
else
{
  //some code
}
is it ok all the best
  #4 (permalink)  
Old January 8th, 2007, 01:28 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is how I'd do it. Use the EditItemTemplate to change properties when editing the record.
Much easier.

<asp:TemplateColumn HeaderText="Fullfillment Extract">
    <ItemTemplate>
        <asp:DropDownList ID="DropdownListFullfilment" Enabled="False" Runat="server" Width="100px"></asp:DropDownList>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:DropDownList ID="DropdownListFullfilment" Enabled="True" Runat="server" Width="100px"></asp:DropDownList>
    </EditItemTemplate>
</asp:TemplateColumn>



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using JS to enable/disable?? crabjoe Javascript 4 November 10th, 2008 06:48 PM
disable the checkbox in edit mode of datagrid swati_joshi ASP.NET 1.0 and 1.1 Professional 3 May 10th, 2007 07:35 AM
disable the checkbox in edit mode of datagrid swati_joshi ASP.NET 1.0 and 1.1 Basics 1 April 20th, 2006 01:44 PM
Disable/Enable elements ldoodle Javascript How-To 3 June 7th, 2005 05:48 AM
Data Grid edit problem rajanikrishna General .NET 2 December 8th, 2004 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.