Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
477 views
Hi,

i have an issue with maintaining state of template column textbox on paging in radgrid.
I am storing the data in session and then on need datasource event trying to get the data again from session.
But this does not help.
Please help me its urgent issue.please refer code below-






<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadGrid ID="grChecklist1" runat="server"  AutoGenerateColumns="false"
            onneeddatasource="grChecklist1_NeedDataSource" 
        onpageindexchanged="grChecklist1_PageIndexChanged" >
   <MasterTableView  AllowPaging="true" AutoGenerateColumns="false"  PageSize="5"> 
    <Columns>
    <telerik:GridTemplateColumn DataField="Number" HeaderText="Number" Visible="true">
    <ItemTemplate>
         <asp:TextBox ID="txtNumber" runat="server" Text='<%#Bind("Number")%>'/>
    </ItemTemplate>
   </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn DataField="TaskDescription" HeaderText="TaskDescription" Visible="true">
    <ItemTemplate>
         <asp:TextBox ID="txtTaskDescription" runat="server" Text='<%#Bind("TaskDescription")%>' />
    </ItemTemplate>
   </telerik:GridTemplateColumn>
   </Columns>

</MasterTableView>
</telerik:RadGrid>
   

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDetails();
            }
        }

        private void LoadDetails()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Number",typeof(string));
            dt.Columns.Add("TaskDescription", typeof(string));
            dt.Rows.Add("1", "task1");
            dt.Rows.Add("2", "task2");
            dt.Rows.Add("3", "task3");
            dt.Rows.Add("4", "task4");
            dt.Rows.Add("5", "task5");
            dt.Rows.Add("6", "task6");
            dt.Rows.Add("7", "task7");
            //grChecklist.DataSource = dt;
           // grChecklist.DataBind();
            Session["dt"] = dt;

        }

        private void RefreshSessionState()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Number", typeof(string));
            dt.Columns.Add("TaskDescription", typeof(string));
            
            foreach (GridDataItem item in grChecklist1.Items)
            {
              string number=(item.FindControl("txtNumber") as TextBox).Text;
              string task = (item.FindControl("txtTaskDescription") as TextBox).Text;
              dt.Rows.Add(number,task);
            }
            if (Session["dt"] != null)
                Session.Remove("dt");
            Session["dt"] = dt;
        }

       

        protected void grChecklist1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
           // RefreshSessionState();
            grChecklist1.DataSource = (DataTable)Session["dt"];

        }

        protected void grChecklist1_PageIndexChanged(object sender, GridPageChangedEventArgs e)
        {
            grChecklist1.AllowPaging = false;
            grChecklist1.Rebind();
           // RefreshSessionState();
           
            grChecklist1.CurrentPageIndex = e.NewPageIndex;
            grChecklist1.AllowPaging = true;
            grChecklist1.Rebind();
        }
    }
Jayesh Goyani
Top achievements
Rank 2
 answered on 15 Nov 2014
9 answers
279 views
Hi,
How to Maintain the state(userid) of checked records  during paging in rad grid?
below is my code for reference.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="True" AllowPaging="True"
           PageSize="5" AllowSorting="True"
           OnNeedDataSource="RadGrid1_NeedDataSource" CellSpacing="0"
           GridLines="None" ShowGroupPanel="True">
           <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
           <ClientSettings Selecting-AllowRowSelect="true" AllowDragToGroup="True">
               <Selecting AllowRowSelect="True"></Selecting>
           </ClientSettings>
           <MasterTableView DataKeyNames="UserId">
               <Columns>
                   <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
               </Columns>
               <PagerStyle AlwaysVisible="True"></PagerStyle>
           </MasterTableView>
       </telerik:RadGrid>
       <br />
       <asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" Width="130px"
           Height="25px" ValidationGroup="val" />
       <br />
and
public partial class GroupUserCreation : System.Web.UI.Page
{
    Globas obj = new Globas();
    CheckBox chkbox = new CheckBox();
    string GroupId="";
  
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
 
            DataTable dt1 = obj.GroupDetails();
            cmbgroupname.DataSource = dt1;
            cmbgroupname.DataTextField = "GroupName";
            cmbgroupname.DataValueField = "GroupId";
            cmbgroupname.DataBind();
        }
      
        
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        
        try
        {
            GroupId = cmbgroupname.SelectedItem.Value.ToString();
            foreach (GridItem item in RadGrid1.MasterTableView.Items)
            {
 
                GridDataItem dataitem = (GridDataItem)item;
                TableCell cell = dataitem["ClientSelectColumn"];
                CheckBox checkBox = (CheckBox)cell.Controls[0];
                if (checkBox.Checked)
                {
                    int userid = Convert.ToInt32(dataitem.GetDataKeyValue("UserId").ToString());
                    if (GroupId != null)
                    {
                        obj.InsertGroupUserCreation(Convert.ToInt32(GroupId), userid);
                    }
                }
 
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
     
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = obj.UserDetails();
        RadGrid1.DataSource = dt;
      
    }
 
 
     
}
Help needed,
Thanks
S
Top achievements
Rank 1
 answered on 15 Nov 2014
1 answer
91 views
I posted this question on StackOverflow: http://stackoverflow.com/questions/26935565/cannot-read-property-length-of-null-using-sender-set-selectedtogglestateinde

It would appear that this telerik thread holds some relevance: http://www.telerik.com/forums/radbutton-javascript-error

Note this issue is in the same project as the RadCombo thread I made: http://www.telerik.com/forums/client-side-eventargs-are-mutable 

Where 'navigating' the client state (control state or view state) using either sender or the event argument is not an issue.



If you could answer this question on SO, I would be greatful, but I do have a general question for this thread post. What is the underline mechanics of how telerik uses the client functions 'get_selectedToggleStateIndex()' or 'get_toggleStates()'.. what is '_functionality' and why is it null in my implementation (i.e. nested function as a promptcallback function)?
Brett
Top achievements
Rank 1
 answered on 14 Nov 2014
1 answer
75 views
Hi,

I'm using a GridTemplateColumn with an Image control in ItemTemplate. I'm using the ItemDataBound event to set the Image background, this all works fine. However when I click on a column to sort all the text columns are sorted correctly but the images do not move.

Here is my code:

ASPX:
<telerik:RadGrid ID="radGrid1" runat="server" AllowSorting="true" OnNeedDataSource="radGrid1_NeedDataSource" OnItemDataBound="radGrid1_ItemDataBound">
  <MasterTableView EditMode="Batch" AllowSorting="true">
    <Columns>
      <telerik:GridClientDeleteColumn ConfirmText="Are you sure?" ImageUrl="~/Images/icoDelete.png" />
      <telerik:GridTemplateColumn HeaderText="Color" UniqueName="RangeColor" DataField="RangeColor" ItemStyle-HorizontalAlign="Center">
          <ItemTemplate>
            <asp:Image ID="imgRangeColor" Height="15" Width="100%" runat="server" />
          </ItemTemplate>
          <EditItemTemplate>
            <telerik:RadColorPicker ID="colorPickerTemplate" runat="server" OnClientLoad="PickerLoad" ShowIcon="true" ShowEmptyColor="false" />
          </EditItemTemplate>
      </telerik:GridTemplateColumn>
    </Columns>
  </MasterTableView>
  <ClientSettings>
    <ClientEvents OnBatchEditGetCellValue="OnBatchEditGetCellValue" OnBatchEditSetCellValue="OnBatchEditSetCellValue" OnBatchEditGetEditorValue="OnBatchEditGetEditorValue" OnBatchEditSetEditorValue="OnBatchEditSetEditorValue" />
  </ClientSettings>
</telerik:RadGrid>

NeedDataSource and ItemDataBound events:
protected void radGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
  myTable = new DataTable();
 
  myTable.Columns.Add("RangeMin");
  myTable.Columns.Add("RangeMax");
  myTable.Columns.Add("ColorAux");
 
  if (ViewState["Table"] != null)
    myTable = (DataTable)ViewState["Table"];
 
  radGrid1.DataSource = myTable;
  ViewState["Table"] = myTable;
}
 
protected void radGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem & e.Item.IsDataBound)
  {
    GridDataItem item = (GridDataItem)e.Item;
 
    string color = ((DataTable)ViewState["Table"]).Rows[item.ItemIndex][2].ToString(); //Get ColorAux value
 
    (item["RangeColor"].FindControl("imgRangeColor") as System.Web.UI.WebControls.Image).BackColor = System.Drawing.ColorTranslator.FromHtml(color);
  }
}


Any sugest how I can fix that problem?

Thanks
Jayesh Goyani
Top achievements
Rank 2
 answered on 14 Nov 2014
8 answers
455 views
I do not want the selected row in a grid to turn dark. How do I turn that off?
Pavlina
Telerik team
 answered on 14 Nov 2014
1 answer
105 views
"Error: Sys.ArgumentException: Cannot deserialize empty string.
Parameter name: data
    at Function.Error$create (http://172.16.17.13/TPS/ScriptResource.axd?d=FXG2eRlUct0x2YANPPo-8ilEesFRotmWUZTTtTbR6ITuuZj3oR3zlBLe_w9PcTm80&t=7eabb20b:847:15)
    at Object.Sys._errorArgument (http://172.16.17.13/TPS/ScriptResource.axd?d=FXG2eRlUct0x2YANPPo-8ilEesFRotmWUZTTtTbR6ITuuZj3oR3zlBLe_w9PcTm80&t=7eabb20b:821:21)
    at Function.Error$argument (http://172.16.17.13/TPS/ScriptResource.axd?d=FXG2eRlUct0x2YANPPo-8ilEesFRotmWUZTTtTbR6ITuuZj3oR3zlBLe_w9PcTm80&t=7eabb20b:870:16)
    at eval (eval at evaluate (unknown source), <anonymous>:1:7)
    at Object.InjectedScript._evaluateOn (<anonymous>:730:39)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:669:52)
    at Object.InjectedScript.evaluateOnCallFrame (<anonymous>:781:21)
    at http://172.16.17.13/TPS/ScriptResource.axd?d=gPSyjbOxvf933YlPqlpl0YmZadBWoP66sOat4oEG8MTKCQNKKtGEnOjuOE0F3Kzm7F4jqlZABy0dzDopQVEKhQ2&t=ffffffff97e4f358:3:9011"

On Save, the changes made on the editor goes away leaving behind the original image loaded in rad image editor .
Secondly this works on My Local machine Very fine but when i deploy it on server the above mentioned exception occurs. i have also tried the solution posted in a thread to increase Json Limit but it does not do anything.
Slav
Telerik team
 answered on 14 Nov 2014
1 answer
370 views
Hi,

I have the following situation: I have multiple self-developed Web User Controls (ascx) in my web application. The user controls are holding different logic, for example a rather complex contact form.

Every page's content on the website, is edited throud RadEditor. Now I need a flexible way to dynamically load page content including one, two, three, x of my own custom user controls....

How can i accomplish this in a neat way with the RadEditor?

My own solution is, in the RadEditor's contentarea, to insert a reference to the user control like %%control:MyFancyUserControl%%, and then at runtime search for %%control:MyFancyUserControl%% and load the control when the page is rendered.
Marin Bratanov
Telerik team
 answered on 14 Nov 2014
13 answers
465 views
How can I avoid the dialog box to save?
I want to save the image directly (AllowedSavingLocation="Server") without the dialog.
I'm saving my edited image to the database....
Niko
Telerik team
 answered on 14 Nov 2014
1 answer
100 views
Is there a way to create a circular border around the gauge as opposed to the wrapper? I'm getting a square border but I would like the border to go around the gauge. I attached an example (gauge1) of what I'm getting and I attached an example (gauge2) of what I am trying to accomplish. Thank you.
Danail Vasilev
Telerik team
 answered on 14 Nov 2014
3 answers
125 views
Setting Enabled = False is not properly styling the RadButton. The disabled="disabled" attribute correctly shows in the generated markup (which causes the correct functionality of it not being able to be clicked); however, the outer anchor tag is not styled with the "rfdInputDisabled" class. I can only reproduce the issue in IE11  (I'm on 11.0.9600.17358). I have a code sample; however, the file filter is not allowing me to attach a .zip file.
Danail Vasilev
Telerik team
 answered on 14 Nov 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?