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

value of GridEditableItem["File"] is &nbsp which is empty space

5 Answers 575 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ghouse
Top achievements
Rank 1
Ghouse asked on 20 Mar 2013, 03:31 PM
I upgraded to new Telerik version 2013.1.220.35 from 2010.3.1109.35. and compatibility issues started...

 

<telerik:RadGrid runat="server" ID="FileListView" AutoGenerateColumns="false" Skin="Windows7" 

Width="100%" OnDeleteCommand="FileListView_DeleteCommand">

<MasterTableView>

<Columns>

<telerik:GridButtonColumn UniqueName="DeleteColumn" ButtonType="ImageButton" CommandName="Delete"

ConfirmTitle="Confirm" ConfirmText="Continue deleting file?" /> <telerik:GridBoundColumn UniqueName="file" DataField="file" Visible="false" ReadOnly="true" />

 <telerik:GridBoundColumn UniqueName="Attachedfiles" DataField="Attached files" HeaderText="File" />

 <telerik:GridBoundColumn UniqueName="Attachedby" DataField="Editor" HeaderText="Attached by" />

 <telerik:GridBoundColumn UniqueName="Attachedat" DataField="Modified" HeaderText="Attached at" />

 </Columns>

 </MasterTableView>

 </telerik:RadGrid>

 

protected void FileListView_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

 {
GridEditableItem editedItem = e.Item as GridEditableItem;

 string filename = editedItem["file"].Text;
logic continues...

but in the above code filename has &nbsp as the value. means filename contains empty space as it value instead of actual file name

Please suggest. 

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Mar 2013, 04:30 AM
Hi,

The value is returning "&nbsp" because Visible property is set as false. Try setting Display property instead and access the value.
aspx:
<telerik:GridBoundColumn UniqueName="file" DataField="file" Display="false" ReadOnly="true" />

Thanks,
Shinu
0
啟仲
Top achievements
Rank 1
answered on 17 Mar 2014, 05:43 AM
Sir:
My code as below, but name still get "&nbsp;",I don't know what happened. 
foreach (GridEditableItem editedItem in (fvESD1.FindControl("GvFieldValue") as RadGrid).EditItems) //將CbCategoryName未選擇欄位隱藏
            {
                
                         string name = editedItem["Name"].Text.Trim();
                         if ((fvESD1.FindControl("CbCategoryName") as RadComboBox).SelectedValue != name)
                        {
                             editedItem.Attributes.Add("style", "display:none");
                                                        
                        }
                    }
               
            }
0
Shinu
Top achievements
Rank 2
answered on 17 Mar 2014, 06:14 AM
Hi,

I'm not clear about your requirement, I guess you want to access values in edit mode on a button click. Please try the below code snippet. If this doesn't help, elaborate on your requirement and provide your aspx page also.

ASPX:
<telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" Display="false" />
<telerik:GridTemplateColumn HeaderText="ShipCountry" DataField="shipCountry">
    <ItemTemplate>
        <%# Eval("ShipCountry") %>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource2" DataTextField="ShipCountry" DataValueField="ShipCountry">
        </telerik:RadComboBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

C#:
//On a button click
protected void btnSave_Click(object sender, EventArgs e)
{
  foreach (GridDataItem item in RadGrid1.EditItems)
  {
    GridEditableItem edititem = (GridEditableItem)item.EditFormItem;
    TextBox txt = (TextBox)edititem["ShipCity"].Controls[0];// Access a bound column in edit
    string name = txt.Text; // gets the text
    RadComboBox combo = (RadComboBox)edititem.FindControl("RadComboBox1");// Access a RadComboBox in template column in edit
    string value = combo.SelectedValue; //gets the selcted value
  }
}

Thanks,
Shinu
0
啟仲
Top achievements
Rank 1
answered on 17 Mar 2014, 07:11 AM
Dear Shinu:

I do my best to list aspx page,because it doesn't attach all file,Thanks!

                            <telerik:GridTextBoxColumnEditor runat="server" ID="MyEditor">  
                              <TextBoxStyle Width="300px" /> 
                            </telerik:GridTextBoxColumnEditor> 
                            
                             <telerik:RadGrid ID="GvFieldValue" runat="server" Height="220px"
                                            AutoGenerateColumns="False" CellSpacing="0"
                                            GridLines="None"
                                            AllowAutomaticUpdates="True" AllowMultiRowEdit="True"
                                            onitemcreated="GvFieldValue_ItemCreated"
                                            onprerender="GvFieldValue_PreRender"
                                            ondatabound="GvFieldValue_DataBound"
                                            onneeddatasource="GvFieldValue_NeedDataSource" Width="500px" >
                                             <ClientSettings>
                                                 <Scrolling AllowScroll="True" ></Scrolling>
                                             </ClientSettings>
                
                                            <MasterTableView InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="InPlace">
                                            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                                            </RowIndicatorColumn>
                                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                                            </ExpandCollapseColumn>
                                                <Columns>
                                                    <telerik:GridBoundColumn DataField="Type"
                                                        FilterControlAltText="Filter Type column" HeaderText="Type"
                                                        UniqueName="Type" ReadOnly="True" Visible="True">
                                                        <FooterStyle Width="80px" />
                                                        <HeaderStyle Width="80px" />
                                                        <ItemStyle Width="80px" />
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Name"
                                                        FilterControlAltText="Filter Name column" HeaderText="Name"
                                                        UniqueName="Name" ReadOnly="True" Visible="True">
                                                        <FooterStyle Width="80px" />
                                                        <HeaderStyle Width="80px" />
                                                        <ItemStyle Width="80px" />
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Seq"
                                                        FilterControlAltText="Filter Seq column" HeaderText="Seq"
                                                        UniqueName="Seq" ReadOnly="True" Visible="True">
                                                        <FooterStyle Width="30px" />
                                                        <HeaderStyle Width="30px" />
                                                        <ItemStyle Width="30px" />
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Value" ColumnEditorID="MyEditor"
                                                        FilterControlAltText="Filter Value column" HeaderText="Value"
                                                        UniqueName="Value" MaxLength="500" Visible="True">
                                                    </telerik:GridBoundColumn>
                                                </Columns>
                                            <EditFormSettings>
                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                            </EditFormSettings>
                                            </MasterTableView>
                                            <FilterMenu EnableImageSprites="False"></FilterMenu>
                                            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
                                  </telerik:RadGrid>​
0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2014, 03:57 AM
Hi,

I guess you want to access the ReadOnly columns in InPlace edit mode. You can set that DataField as DataKeyNames and access it in the code behind as follows:

ASPX:
<MasterTableView DataKeyNames="Name">

C#:
foreach (GridDataItem item in GvFieldValue.EditItems)
{
 string val = item.GetDataKeyValue("Name").ToString();
}

Also take a look at this article on Updating Values Using InPlace and EditForms Modes

Thanks,
Shinu
Tags
Grid
Asked by
Ghouse
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
啟仲
Top achievements
Rank 1
Share this question
or