This is a migrated thread and some comments may be shown as answers.

Radgrid

5 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Parodist
Top achievements
Rank 1
Parodist asked on 24 Mar 2009, 07:58 AM
Hi,

I have a raggrid containing 4 columns,first column being the rowId and lastcolumn being the GridDropdownColumn.
And I have to update just the lastcolumn which is the  GridDropdownColumn using an in-line  auto update however while updating it I need to give a condition based on rowId .So how can I update based on the selected rowid?


Thanking you in advance.


5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Mar 2009, 09:59 AM
Hello Parodist,

You can set rowId as the DataKeyName for the MasterTableView and then access the rowId in the update event handler as shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="AccessDataSource1" OnUpdateCommand="RadGrid1_UpdateCommand"
         <MasterTableView EditMode="InPlace" DataKeyNames="RowID" DataSourceID="AccessDataSource1" AutoGenerateColumns="False"
                ..... 

c#:
 
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {              
            GridEditableItem editItem = (GridEditableItem)e.Item;  
            string rowId = editItem.GetDataKeyValue("RowID").ToString(); //to access the rowId 
            RadComboBox rdcbx = (RadComboBox)editItem["DropDownColumnUniqueName"].Controls[0]; //to access the combobox 
          
    } 

Thanks
Princy.
0
Parodist
Top achievements
Rank 1
answered on 24 Mar 2009, 05:30 PM
Thanks ever so much Princy.I have another radgrid to display - 3 columns basicaly,the last column is the status  column(boolean) by default 'Yes' with GridCheckBoxColumn to be checked  on display and uncheck on click of edit button.How can I do this.


Thanking you in advance
0
Princy
Top achievements
Rank 2
answered on 25 Mar 2009, 06:19 AM
Hi Parodist,

I suppose you are trying to uncheck the GridCheckBoxColumn when it is in EditMode. If that is the case then you can access the checkbox and then uncheck it as shown in the code below:
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            ((CheckBox)editItem["CheckBoxColumnUniqueName"].Controls[0]).Checked = false
        } 
    } 

Thanks
Princy.
0
Parodist
Top achievements
Rank 1
answered on 25 Mar 2009, 08:27 AM
Thanks for the early response Princy,if I use asp:checkbox ,it seems to work fine but when I use 

<telerik

:GridCheckBoxColumn></telerik:GridCheckBoxColumn> it displays faded check boxes and if I specify its properties like uniquename,datafield etc it gives 'String was not recognized as a valid Boolean'  but how can I make these checked boxes to display checked by default as I have set it as boolean from the backend and how can I bind it?

 

0
Shinu
Top achievements
Rank 2
answered on 25 Mar 2009, 09:31 AM
Hi Parodist,

GridCheckBoxColumn will always show the CheckBox as disabled in normal mode and it will be enabled only in edit mode. If you want the checkbox to be enabled in normal mode you may consider using a GridTemplateColumn with CheckBox in its ItemTemplate as shown below.

ASPX:
 
 
<telerik:GridTemplateColumn UniqueName="TempCheckCol" HeaderText="TempCheckCol"  > 
                      <ItemTemplate> 
                          <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#Eval("Discontinued") %>' /> 
                      </ItemTemplate> 
  </telerik:GridTemplateColumn> 


Thanks
Shinu
Tags
Grid
Asked by
Parodist
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Parodist
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or