Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
273 views
HI,

I need to add a RequiredFieldValidator to the grid. The columns are autogenerated. 
I was able to acess the column value in the InsertCommand untill I added the below code to the ItemDataBound.
How do I acess the columns in the InsertCommand?

Thanks for your help!!

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 
       {
 
 if ((e.Item is GridEditableItem && e.Item.IsInEditMode))
 
           {
 
               GridEditableItem item = e.Item as GridEditableItem;
 
               GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor(Convert.ToString(ViewState["ColName"]));
 
               TableCell cell = (TableCell)editor.TextBoxControl.Parent;
 
  
 
               RequiredFieldValidator validator = new RequiredFieldValidator();
 
               editor.TextBoxControl.ID = "txtValue";
 
               validator.ControlToValidate = editor.TextBoxControl.ID;
 
               validator.ErrorMessage = "*";
 
               cell.Controls.Add(validator);
 
  
 
      
 
           }
 
       }
 
  
 
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
 
       {
 
           string tableName = rcbLkup.SelectedValue;
 
           GridDataInsertItem row = (GridDataInsertItem)e.Item;
 
  
 
           BLL_LkupMaintenance objLkup = new BLL_LkupMaintenance();
 
  
 
           objLkup.ColName = Convert.ToString(ViewState["ColName"]);
 
           //objLkup.LkupValue = row[objLkup.ColName].Text;
 
           objLkup.LkupValue = ((TextBox)row.Controls[4].Controls[0]).Text;
 
           objLkup.AddToLkupTable(tableName);
 
  
 
       }

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        CellSpacing="0" GridLines="None"
    onprerender="RadGrid1_PreRender" onupdatecommand="RadGrid1_UpdateCommand"
        oninsertcommand="RadGrid1_InsertCommand"
        onitemdatabound="RadGrid1_ItemDataBound" >
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
        <MasterTableView EditMode="InPlace" DataKeyNames="ID" CommandItemDisplay="Top" >
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
                </telerik:GridEditCommandColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>
Jagat
Top achievements
Rank 1
 answered on 20 Feb 2012
3 answers
261 views
hello,
i'm developing a web application that contains tabstrip control , multipage pageview controls,i have a button and through this button i want to navigate through tabs using ajax everything was working ok until i've added the prometheus editor in my page the following error was raised
The PageRequestManager cannot be initialized more than once."
this error is raised on "IE7" but in firefox it was running ok
i think the  cause of the problem from  asp:script manager as i've got the following warnings
Assuming assembly reference 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy        
 
please note that i'm using Rad ajax manager v 1.8.1.0,VS 2008 beta1
is there any way to solve this problem

Thank You
Ibrahim Imam

Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
233 views
Hi, i am using rad editor in wysiwyg mode.

I need to insert some text to cursor position.

before paste some text, i need to check some condition like, the given cursor position is center/left/right of the particular elememt.

My code like
var selectedtag = editor.getSelectedElement();
                      var range = editor.getSelection().getRange();
                      var selection = editor.getSelection();
                      if (selectedtag.tagName != "LI" && selectedtag.tagName != "P") {
                          var sel = editor.getSelection().getText();
                          var text = selectedtag.innerHTML;
                          //range.pasteHTML('<p>' + sel + '</p>');
                           selectedtag.innerHTML = '<p>' + text;
                          
 
 
                      }
                      else if (selectedtag.tagName == "LI") {
                          var sel = editor.getSelection().getText();
                          if (sel == "") {
                              range.pasteHTML('</li><li>...</li>');
                          }
                          else {
                              range.pasteHTML('</li><li>' + sel + '</li>');
                          }
                      }
                      else if (selectedtag.tagName == "P") {
                          var sel = editor.getSelection().getText();
                          if (sel == "") {
                              range.pasteHTML('</p><p>');
                          }
                          else {
                              range.pasteHTML('</p><p>' + sel + '</p>');
                          }
                      }
                      else {
                          var sel = editor.getSelection().getText();
                          if (sel == "") {
                              range.pasteHTML('</p><p>');
                          }
                          else {
                              range.pasteHTML('</p><p>' + sel + '</p><p>');
                          }
                      }
i got the range.
But , how to check if the selected text has any text before and after.

I need to implement some text based on the condition like,

Te  Text to the left is empty (ie selection is at the start of the element): <p> selected text text to the right</p>

3)  Text to the right is empty (ie selection is at the end of the element): <p>Text to the left selected text </p>

i need the output like,

<p> selected text</p><p>text to the right</p>

How to check if the selected text /range contains any text before and after the selected text.

This is urgent requirement.
Thanks ,
Uma



Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
71 views
I am interested in using Telerik RadSpell client side.  My specific need is that I want to be able to control the action performed on the replaced/corrected words.  Is there a way to bind to an event that will allow me to custom wrap the corrected word in some additional HTML?
 
Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
161 views
Hi Telerik,

In one of my application,In one page i am using radeditor in that,i want to give more than 8000 characters.Is it possible or not?

Thanks in Advance.
Ur's
Sekhar
Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
78 views
Hi,
In time view i need to show all Employee names.By clicking employee name i need to show his/her Department,Sex, etc.For Example at 8 PM i have 10 employees.So i need to show 10 employee name and each employee has detail button.While clicking the button user should able to view his details.
Ivana
Telerik team
 answered on 20 Feb 2012
4 answers
1.1K+ views
Hi

I am having a problem at the moment removing a row from the RadGrid client side.

Our RadGrid is built up via xml defined from a generic RadGrid declaration. On the particular page i am trying to remove a row i have the following defined (where index is the row selected):

function DeleteRow(index)
{
     var masterTable = $find('<%=RadGrid1.ClientID=>').get_masterTableView();
     masterTable.deleteItem(masterTable.get_dataItems()[index].get_element());
}

The problem is that function deletes all rows in my grid and not the index that i supplied it. I have checked the index value and can confirm that changes to the row i have clicked on. Can you provide an alternative solution?

Regards,
Jonathan
Elliott
Top achievements
Rank 2
 answered on 20 Feb 2012
3 answers
555 views
Hi,

please see this example: when the DoSomething button is pressed, ReBind() is called twice. The second time, the RadGrid does not refresh.

public partial class _default : System.Web.UI.Page
{
  protected override void OnInit(EventArgs e)
  {
    if (!IsPostBack)
    {
      Session["data"] = new List<string>() { "ready", "ready" };
    }
    base.OnInit(e);
  }
 
  protected DataTable GetGridDataTable()
  {
    List<string> data = Session["data"] as List<string>;
     
    DataTable dataTable = new DataTable();
    dataTable.Columns.Add("Name");
 
    foreach (string s in data)
    {
      dataTable.Rows.Add(s);
    }
    return dataTable;
  }
 
  protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
  {
    RadGrid1.DataSource = GetGridDataTable();
  }
 
  protected void Button_Click(object sender, EventArgs e)
  {
    Session["data"] = new List<string>() { "loading", "loading" };
    RadGrid1.Rebind();
    System.Threading.Thread.Sleep(2000);
    Session["data"] = new List<string>() { "finished", "finished" };
    RadGrid1.Rebind();
  }
}
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" Width="400px">
            <MasterTableView DataKeyNames="Name" Name="ParentTable">
                <Columns>
                    <telerik:GridBoundColumn DataField="Name" UniqueName="Name">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <asp:Button Text="Do something" OnClick="Button_Click" runat="server"/>
    </div>
    </form>
</body>
</html>

Right now, after the button is pressed, the grid displays "loading", but then does not display "finished". How would I get RadGrid to correctly display "loading" and then "finished"?
Thanks,
Donald
Andrey
Telerik team
 answered on 20 Feb 2012
2 answers
171 views
How t avoid postback in radcalendar when a date is selected.
Vasil
Telerik team
 answered on 20 Feb 2012
1 answer
147 views
Hello,

I have a RadScriptManager on a form along with a RadGrid.  I have an issue where 2 users (both with IE7 browsers) are able to populate the grid fine on their first try, but then sometimes have issues on subsequent attempts. There is a ‘Refresh’ button on the screen and it’ll usually work, but fails intermittently (usually after they’ve waited some time to refresh the report). 

I’m not able to recreate on my IE8 browser and the users currently don’t wish to upgrade from IE7.  Is this a known issue with IE7 and ScriptManager?  Is there any resolution to this issue?  This is the exact error that the users get:  “Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

Thanks.
Pavlina
Telerik team
 answered on 20 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?