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

Row data vanishes while edit mode is true in Rad Grid

5 Answers 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jongalala
Top achievements
Rank 1
Jongalala asked on 29 Jul 2013, 12:23 PM

<
Rad:RadGrid Height="350px" Width="100%" ID="RadGridFields" Skin="Windows7" BorderStyle="Solid" runat="server" AllowPaging="True"
    GridLines="None" AllowMultiRowEdit="true" AllowAutomaticUpdates="True" AllowSorting="True" AllowMultiRowSelection="false"
    OnUpdateCommand="RadGridFields_UpdateCommand" OnNeedDataSource="RadGridFields_NeedDataSource" OnItemDataBound="RadGridFields_ItemDataBound" AutoGenerateColumns="false">
 
    <MasterTableView TableLayout="Fixed" DataKeyNames="LabelText" EditMode="InPlace" AllowPaging="false" Width="100%" NoMasterRecordsText="">
      <Columns>
        <Rad:GridEditCommandColumn HeaderText="Edit" HeaderStyle-Width="55px" ButtonType="ImageButton" EditText="Edit" UniqueName="EditCol" />
 
        <Rad:GridTemplateColumn UniqueName="LabelText" HeaderText="LabelText" HeaderStyle-Width="200px" DataField="LabelText">
          <ItemTemplate>
            <%#DataBinder.Eval(Container.DataItem, "LabelText")%>
          </ItemTemplate>
          <EditItemTemplate>
            <Rad:RadTextBox runat="server" ID="textLabel" AutoPostBack="true" Height="140px" Width="200px" />
          </EditItemTemplate>
        </Rad:GridTemplateColumn>
 
        <Rad:GridTemplateColumn UniqueName="Mandatory" HeaderText="Mandatory" HeaderStyle-Width="80px" DataField="Mandatory">
          <ItemTemplate>
            <%#DataBinder.Eval(Container.DataItem, "Mandatory")%>
          </ItemTemplate>
          <EditItemTemplate>
            <Rad:RadComboBox runat="server" ID="comboMandatory" AutoPostBack="true" HighlightTemplatedItems="true" Height="140px" Width="80px" DropDownWidth="200px" OnSelectedIndexChanged="comboMandatory_SelectedIndexChanged" >
            <Items>
               <Rad:RadComboBoxItem Value="False" Text="False" />
               <Rad:RadComboBoxItem Value="True" Text="True" />
            </Items>
            </Rad:RadComboBox>
          </EditItemTemplate>
        </Rad:GridTemplateColumn>
 
        <Rad:GridTemplateColumn UniqueName="DefaultText" HeaderText="DefaultText" HeaderStyle-Width="200px" DataField="DefaultText">
          <ItemTemplate>
            <%#DataBinder.Eval(Container.DataItem, "DefaultText")%>
          </ItemTemplate>
          <EditItemTemplate>
            <Rad:RadTextBox runat="server" ID="textDefault" AutoPostBack="true" Height="140px" Width="200px" />
          </EditItemTemplate>
        </Rad:GridTemplateColumn>
      </Columns>
    </MasterTableView>
 
    <ClientSettings>
      <ClientEvents OnRowDblClick="editThisRow" OnCommand="onClientCommand" />
      <Scrolling AllowScroll="true" ScrollHeight="100%" />
      <Selecting AllowRowSelect="true" />
    </ClientSettings>
  </Rad:RadGrid>

I want to show some data on a radgrid. I want all the columns texts to be editable from the beginning. Later I want to save the data. Above I have given my code in ascx control. Noe this is my code in cs page 

protected void Page_Load(object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
     RadGridFields.DataSource = gridTable;
    RadGridFields.DataBind();
 
    foreach (GridDataItem item in RadGridFields.MasterTableView.Items)
    {
      item.Edit = true;
    }
    RadGridFields.Rebind();
      }
    }
  }

When I run this all the columns become editable. But all the checkboxes contain false value and all textboxes contain blank value. I want previous datas to be there and from that data user can edit. If I remove 
foreach (GridDataItem item in RadGridFields.MasterTableView.Items)
    {
      item.Edit = true;
    }
    RadGridFields.Rebind();
      }

this part from code then all datas are there..when I double click on the then the row's data vanishes. Need Help..Thanks in advanced

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 29 Jul 2013, 01:10 PM
Hi,

Please bind the radgrid using Advanced Data-binding (using NeedDataSource event).Then to set the rows in edit mode,please try the following code snippet.

C#:
protected void RadGridFields_PreRender(object sender, EventArgs e)
{
  foreach (GridDataItem data in RadGridFields.MasterTableView.Items)
   {
      data.Edit = true;
   }
  RadGridFields.Rebind();   
}

Thanks,
Princy
0
Jongalala
Top achievements
Rank 1
answered on 29 Jul 2013, 01:15 PM
I have tried in this way also..doesn't work :( :(
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Jul 2013, 01:56 PM
Hello,

Please use either "NeeddataSource" or manually assigned the datasource.

Manually:

protected void RadGridFields_PreRender(object sender, EventArgs e)
{
  foreach (GridDataItem data in RadGridFields.MasterTableView.Items)
   {
      data.Edit = true;
   }
  RadGridFields.DataSource = gridTable;
    RadGridFields.DataBind();
 
 
}



Thanks,
Jayesh Goyani
0
Jongalala
Top achievements
Rank 1
answered on 29 Jul 2013, 06:17 PM
I have tried using NeeddataSource and manually (using one at a time). But the problem is not solved. I don't know what I am missing here. Frustrating problem :(
0
Princy
Top achievements
Rank 1
answered on 30 Jul 2013, 03:16 AM
Hi,

Can you please provide your full code of C# and ASPX,so that I may check the issue.

Thanks,
Princy
Tags
Grid
Asked by
Jongalala
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Jongalala
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or