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

6 posts, 0 answers
  1. Ghouse
    Ghouse avatar
    6 posts
    Member since:
    Mar 2013

    Posted 20 Mar 2013 Link to this post

    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. 

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Mar 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. 啟仲
    啟仲 avatar
    8 posts
    Member since:
    Mar 2014

    Posted 17 Mar 2014 in reply to Shinu Link to this post

    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");
                                                            
                            }
                        }
                   
                }
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Mar 2014 in reply to 啟仲 Link to this post

    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
  6. 啟仲
    啟仲 avatar
    8 posts
    Member since:
    Mar 2014

    Posted 17 Mar 2014 in reply to Shinu Link to this post

    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>​
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Mar 2014 in reply to 啟仲 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017