Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
487 views
Hi,

I have a problem with RadData Grid.
I am using InPlace edit/insetrt/delete in my grid with the help of following url
http://www.telerik.com/help/aspnet/grid/grdinsertingvaluesinplaceandeditforms.html 

My scenario is am Insert/Update/Delete data within radgrid not in database with Inplace technology that mean DataSource is local DataTable and and actual Database reflect with all header & Details(RadGrid) Save.

My problem is if I run my code with the break point in NeedDataSource event it is working fine and run without breakpoint it will gives an error like :
Microsoft JScript runtime error: Unable to get value of the property 'removeChild': object is null or undefined.

My scenario like user never save data if radgrid is in Edit mode (Grid row with textboxes). He have to finished the radgrid editing.
And my problem arising from hear if I clicks save button without complete radgrid editing and user try to click Insert that error occurred. 

My Code is :

private DataTable GridSource
{
    get
    {
Object obj = this.ViewState["_gds"];
if (obj != null)
{
   return (DataTable)obj;
}
else
{
   DataTable dtTable = null;
   try
   {
XtraTechnician.DAL.ServiceRecommendationMaterial serviceRecommendationMaterial = new XtraTechnician.DAL.ServiceRecommendationMaterial();
string connectionString = ConfigurationManager.ConnectionStrings["xtramec_dbConnectionString"].ToString();
SqlConnection connection = new SqlConnection(connectionString);
if (Request.QueryString["RecoId"] != null && Request.QueryString["RecoId"].ToString().Trim() != string.Empty && Request.QueryString["RecoId"] != "N/A")
{
   serviceRecommendationMaterial.RecommendationId = Convert.ToInt32(Request.QueryString["RecoId"]);
}
dtTable = serviceRecommendationMaterial.GetServiceRecommendationMaterialByRecommendationId(connection);
   }
   catch (Exception ex)
   {
   }
   this.ViewState["_gds"] = dtTable;
   return dtTable;
}
    }
}

protected void rgMaterials_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
     rgMaterials.DataSource = this.GridSource;
}

protected void rgMaterials_InsertCommand(object sender, GridCommandEventArgs e)
{
    try
    {
GridEditableItem editedItem = e.Item as GridEditableItem;
DataTable materialTable = this.GridSource;

DataRow newRow = materialTable.NewRow();

//As this example demonstrates only in-memory editing, a new primary key value should be generated
//This should not be applied when updating directly the database
DataRow[] allValues = materialTable.Select("", "RecommendationId", DataViewRowState.CurrentRows);
if (allValues.Length > 0)
{
   newRow["RecommendationId"] = (int)allValues[allValues.Length - 1]["RecommendationId"] + 1;
}
else
{
   newRow["RecommendationId"] = 1; //the table is empty;
}

//Set new values
System.Collections.Hashtable newValues = new System.Collections.Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);

try
{
   foreach (System.Collections.DictionaryEntry entry in newValues)
   {
                newRow[(string)entry.Key] = entry.Value;
   }
}
catch (Exception ex)
{
   e.Canceled = true;
}

materialTable.Rows.Add(newRow);
//Code for updating the database ca go here...
e.Canceled = true;
rgMaterials.MasterTableView.IsItemInserted = false;
Session["IsMaterial"] = true;
rgMaterials.DataSource = null;
rgMaterials.Rebind();
    }
    catch (Exception)
    {
Session["IsMaterial"] = false;
return;
    }
}

protected void btnSave_Click(object sender, EventArgs e)
{
    if (Session["IsMaterial"] != null)
    {
if (Convert.ToBoolean(Session["IsMaterial"]) == true)
{
   int iRecommendation = 0;
   if (Request.QueryString["RecoId"].ToString().Trim() == string.Empty || Request.QueryString["RecoId"].ToString().Trim() == " " || Request.QueryString["RecoId"].ToString().Trim() == "N/A")
   {
try
{
   XtraTechnician.DAL.ServiceRecommendation serviceRecommendation = new XtraTechnician.DAL.ServiceRecommendation();
   string connectionString = ConfigurationManager.ConnectionStrings["xtramec_dbConnectionString"].ToString();
   SqlConnection connection = new SqlConnection(connectionString);
   if (Request.QueryString["wo"] != null)
   {
serviceRecommendation.WorkOrderId = lblWorkOrderValue.Text;
   }
   if (Request.QueryString["tag"] != null)
   {
serviceRecommendation.EquipmentId = lblTagValue.Text;
   }
   if (Session["SESSION_CUSTOMER_ID"] != null)
   {
serviceRecommendation.TechnicianUserId = Session["SESSION_CUSTOMER_ID"].ToString();
   }
   serviceRecommendation.Date = Convert.ToDateTime(txtDate.SelectedDate);
   if (rbResponsibilityXtra.Checked)
   {
serviceRecommendation.Responsibility = "x";
   }
   else if (rbResponsibilityCustomer.Checked)
   {
serviceRecommendation.Responsibility = "c";
   }
   if (ddlStatus.SelectedIndex > -1)
   {
if (ddlStatus.SelectedValue == "0")
{
   serviceRecommendation.Status = "A";
}
else if (ddlStatus.SelectedValue == "1")
{
   serviceRecommendation.Status = "I";
}
   }
   if (txtMachanic.Text != string.Empty)
   {
serviceRecommendation.MechanicHours = Convert.ToDecimal(txtMachanic.Text);
   }
   else
   {
serviceRecommendation.MechanicHours = Convert.ToDecimal(0);
   }
   if (txtApprentice.Text != string.Empty)
   {
serviceRecommendation.ApprenticeHours = Convert.ToDecimal(txtApprentice.Text);
   }
   else
   {
serviceRecommendation.ApprenticeHours = Convert.ToDecimal(0);
   }
   if (txtOvertime.Text != string.Empty)
   {
serviceRecommendation.OvertimeHours = Convert.ToDecimal(txtOvertime.Text);
   }
   else
   {
serviceRecommendation.OvertimeHours = Convert.ToDecimal(0);
   }
   serviceRecommendation.Comments = txtComments.Text;
   serviceRecommendation.QuoteId = Convert.ToInt32(0);
   iRecommendation = serviceRecommendation.InsertServiceRecommendationOnSave(connection);
   lblRecommendationValue.Text = iRecommendation.ToString();
}
catch (Exception ex)
{
   return;
}
   }
   else
   {
lblRecommendationValue.Text = Request.QueryString["RecoId"].ToString();
iRecommendation = Convert.ToInt32(Request.QueryString["RecoId"]);
try
{
   XtraTechnician.DAL.ServiceRecommendation serviceRecommendation = new XtraTechnician.DAL.ServiceRecommendation();
   string connectionString = ConfigurationManager.ConnectionStrings["xtramec_dbConnectionString"].ToString();
   SqlConnection connection = new SqlConnection(connectionString);
   serviceRecommendation.RecommendationId = iRecommendation;
   if (Request.QueryString["wo"] != null)
   {
serviceRecommendation.WorkOrderId = lblWorkOrderValue.Text;
   }
   if (Request.QueryString["tag"] != null)
   {
serviceRecommendation.EquipmentId = lblTagValue.Text;
   }
   if (Session["SESSION_CUSTOMER_ID"] != null)
   {
serviceRecommendation.TechnicianUserId = Session["SESSION_CUSTOMER_ID"].ToString();
   }
   serviceRecommendation.Date = Convert.ToDateTime(txtDate.SelectedDate);
   if (rbResponsibilityXtra.Checked)
   {
serviceRecommendation.Responsibility = "x";
   }
   else if (rbResponsibilityCustomer.Checked)
   {
serviceRecommendation.Responsibility = "c";
   }
   if (ddlStatus.SelectedIndex > -1)
   {
if (ddlStatus.SelectedValue == "0")
{
   serviceRecommendation.Status = "A";
}
else if (ddlStatus.SelectedValue == "1")
{
   serviceRecommendation.Status = "I";
}
   }
   if (txtMachanic.Text != string.Empty)
   {
serviceRecommendation.MechanicHours = Convert.ToDecimal(txtMachanic.Text);
   }
   else
   {
serviceRecommendation.MechanicHours = Convert.ToDecimal(0);
   }
   if (txtApprentice.Text != string.Empty)
   {
serviceRecommendation.ApprenticeHours = Convert.ToDecimal(txtApprentice.Text);
   }
   else
   {
serviceRecommendation.ApprenticeHours = Convert.ToDecimal(0);
   }
   if (txtOvertime.Text != string.Empty)
   {
serviceRecommendation.OvertimeHours = Convert.ToDecimal(txtOvertime.Text);
   }
   else
   {
serviceRecommendation.OvertimeHours = Convert.ToDecimal(0);
   }
   serviceRecommendation.Comments = txtComments.Text;
   serviceRecommendation.QuoteId = Convert.ToInt32(0);
   serviceRecommendation.UpdateRecommendationByRecommendationId(connection);
}
catch (Exception ex)
{
   return;
}
   }
   if (iRecommendation > 0)
   {
try
{
   XtraTechnician.DAL.ServiceRecommendationMaterial serviceRecommendationMaterial = new XtraTechnician.DAL.ServiceRecommendationMaterial();
   string connectionString = ConfigurationManager.ConnectionStrings["xtramec_dbConnectionString"].ToString();
   SqlConnection connection = new SqlConnection(connectionString);
   serviceRecommendationMaterial.RecommendationId = iRecommendation;
   serviceRecommendationMaterial.DeleteByRecommendationId(connection);
}
catch (Exception)
{
   return;
}
try
{
   foreach (GridDataItem item in rgMaterials.MasterTableView.Items)
   {
XtraTechnician.DAL.ServiceRecommendationMaterial serviceRecommendationMaterial = new XtraTechnician.DAL.ServiceRecommendationMaterial();
string connectionString = ConfigurationManager.ConnectionStrings["xtramec_dbConnectionString"].ToString();
SqlConnection connection = new SqlConnection(connectionString);
serviceRecommendationMaterial.RecommendationId = iRecommendation;
serviceRecommendationMaterial.PartNumber = item["PartNumber"].Text;
serviceRecommendationMaterial.Comment = item["Comment"].Text;
serviceRecommendationMaterial.Price = Convert.ToDecimal(((Label)item["Price"].FindControl("lblPrice")).Text.Remove(0, 1));     //Convert.ToDecimal(item["Price"].Text);     //Convert.ToDecimal(item["TemplateColumn"]);
//(TextBox)item["Name"].FindControl("TextBox1");
serviceRecommendationMaterial.InsertServiceRecommendationMaterial(connection);
   }
}
catch (Exception ex)
{
   return;
}
   }


   try
   {
XtraTechnician.DAL.ServiceOrderDetail serviceOrderDetail = new XtraTechnician.DAL.ServiceOrderDetail();
string connectionString = ConfigurationManager.ConnectionStrings["xtramec_dbConnectionString"].ToString();
SqlConnection connection = new SqlConnection(connectionString);
if (Request.QueryString["wo"] != null)
{
   serviceOrderDetail.WorkOrderId = Request.QueryString["wo"].ToString();
}
if (Request.QueryString["tag"] != null)
{
   serviceOrderDetail.EquipmentId = Request.QueryString["tag"].ToString();
}
if (lblRecommendationValue.Text != string.Empty)
{
   serviceOrderDetail.RecommendationId = Convert.ToInt32(lblRecommendationValue.Text);
}
serviceOrderDetail.UpdateServiceOrderDetailRecommendationIdByEquipmentIdWorkOrderId(connection);
   }
   catch (Exception ex)
   {
return;
   }
   if (Request.QueryString["wo"] != null && Request.QueryString["tag"] != null)
   {
if (Request.QueryString["ref"] != null)
{
   if (Request.QueryString["ref"].ToString() == "em")
   {
Response.Redirect("EquipmentMaintenance.aspx?tag=" + Request.QueryString["tag"].ToString() + "&wo=" + Request.QueryString["wo"].ToString() + "");
   }
   else if (Request.QueryString["ref"].ToString() == "woe")
   {
Response.Redirect("WorkOrderEquipment.aspx?wo=" + Request.QueryString["wo"].ToString() + "");
   }
}
   }
}
else
{
   RadWindowManager1.RadAlert("Finish material job before recommendation data save!", 400, 120, "XtraTechnician Alert", "");
}
    }
}

protected void rgMaterials_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    switch (e.CommandName)
    {
case "Select":
   Session["SESSION_WORKORDER"] = e.Item.Cells[2].Text.ToString();
   Session["SESSION_CUSTOMERNAME"] = e.Item.Cells[10].Text.ToString();
   Session["SESSION_BUILDINGNAME"] = e.Item.Cells[7].Text.ToString() + "-" + e.Item.Cells[11].Text.ToString();
   Response.Redirect("WorkOrderEquipment.aspx");
   break;
case RadGrid.InitInsertCommandName:
   Session["IsMaterial"] = false;
   break;
case RadGrid.EditCommandName:
   Session["IsMaterial"] = false;
   break;
    }
}

I am sending screen shots also.
Andrey
Telerik team
 answered on 29 Dec 2011
2 answers
74 views
Hi everyone. I want to use a Telerik grid to display the results of a SQL View. I was hoping I could find some code that I could read, get the jist of what it was doing, modify it and get going but I can't find anything. At this linkhttp://demos.telerik.com/aspnet-ajax/grid/examples/clientbinding/defaultcs.aspx the grid control is the one I want to use (3.5 and supports the sort) and it does have sample code but of the three examples it's all a lot of new programming style for me. The example that uses WCF looks promising. With the WCF route can I use a MSSQL View or use the statements of the View in a web service? I have over 600 Views to do so I don't want to do much work in getting a View ready. I want to be able to use the View by name or copy an paste its definition. With that being said can someone help me use my existing Views code to get the data displayed in a Telerik Grid with or without the examples from the provided link? Super please.
Juan
Top achievements
Rank 1
 answered on 29 Dec 2011
1 answer
91 views
In Each Callback of AjaxPanel the AjaxPanel and the containers inside the AjaxPanel shrinks, is there any easy way to prevent it?

 

 

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">

</telerik:RadScriptManager>

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">

</telerik:RadAjaxLoadingPanel>

 

 

<

 

 

telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server" >

 

<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>

 

</telerik:RadAjaxPanel>

Iana Tsolova
Telerik team
 answered on 29 Dec 2011
2 answers
120 views
the following code worked fine in 2010 version but throws exceptions in 2011.3.3115.35

protected void cmbShipDate_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
    string filterExpression;
    filterExpression = RemoveFilter("ShipDate");
    rgEditOrder.MasterTableView.FilterExpression = filterExpression;
    if (cmbShipDate.SelectedItem.Text == "All")
        filterExpression = string.Empty;
    else
        filterExpression = "([ShipDate] = '" + cmbShipDate.SelectedItem.Text + "')";
    rgEditOrder.MasterTableView.FilterExpression = AppendFilterExpression(filterExpression);
    rgEditOrder.EditIndexes.Clear();
    ClearOutItemData();
    rgEditOrder.MasterTableView.Rebind();
}
 
private string AppendFilterExpression(string filterExpression)
{
    StringBuilder sb;
    sb = new StringBuilder(rgEditOrder.MasterTableView.FilterExpression);
    if (filterExpression == string.Empty)
        return sb.ToString();
    if (sb.ToString() != string.Empty)
    {
        sb.Append(" AND ");
    }
    sb.Append(filterExpression);
    return sb.ToString();
}

what gives?
Elliott
Top achievements
Rank 2
 answered on 29 Dec 2011
2 answers
138 views
Hi,
My scenario is like below:
1: There is an  asp.net UpdatePnale that I defined a RadGrid inside it.
2: I have defined a Pager Template for RadGrid. Template is a user control that contains some javascript and some server controls to navigate RadGrid.(Javasripts used for client events)
3: RadGrid shows some result search and it will appear when user clicks search button and updates UpdatePanel. So there is no any RadGrid in page at first view .
4: My javascript codes of pager uc is rounded by RadScriptBock tag.

My problem is:
1: When I click search button, server fill RadGrid and it appears correctly. But all client evenst that i have attached to pager uc server controls are undefinded and Javascript  error appears in the page. This causes that some controls like RadCombobox renders incorectly.
2: When I click next page button of pager, after server response, all things become ok. So my problem is at first view of appearing RadGrid.

My Idea:
I think when request handles by asp.net update panel it ignores my javascript block . But second time that request handles by RadAjaxManager it registers my javascipts correctly. Am i right? Is there any solution for this?

Any Idea or solution is appreciated.
 
 
mohsen
Top achievements
Rank 1
 answered on 29 Dec 2011
4 answers
133 views
Hei,

about this example:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=grid

I have problem to show the images upload button. (it dont show at all on the page)

I have also problem with this: (data dont show)

 <EditItemTemplate>
  <telerik:RadTextBox ID="txbDescription" Width="370px" runat="server" TextMode="MultiLine"
  Text='<%# Bind("Description") %>' Height="150px" />
 </EditItemTemplate>


When a replace the <telerik:Radtextbox> with an <asp:TextBox> then the data shown

Is there anyone who can give me some good advice? or is there some better examples that I can use.

Best regards

Rune

Antonio Stoilkov
Telerik team
 answered on 29 Dec 2011
1 answer
164 views
Hi,

I am not able to get ContextMenu Item on ContextMenuItemClick events after adding context menu item on client side.

 function ClientContextMenuShowing(sender, eventArgs) {
 menu = eventArgs.get_menu();
 var newItem = new Telerik.Web.UI.RadMenuItem();
 newItem.set_text('Test');
 newItem.set_value('1');
menu.get_items().add(newItem);
}

Please help.
Princy
Top achievements
Rank 2
 answered on 29 Dec 2011
2 answers
117 views
Hello,

Recently i have been working on radrecurrenece editor, i wanted to customize end by datepicker calendar how to do that ,please respond thanks.

Regards,
Madhukar.
Saimadhukar
Top achievements
Rank 1
 answered on 29 Dec 2011
2 answers
105 views
Hi,

Let us say our list is as follows:

1. Raghu
2. Ram
3. Gandhi
4. Raghu

Though the user selects the 4th Raghu, the selected item that is being sent to the server is the 1st Raghu!

I remember this being mentioned as a known issue somewhere in the forum. However, in my case, there is no way to actually ensure that the text of the item is going to be unique because the list being shown actually is a list of persons. This is really a deal breaker for me!

Any ideas on how to fix this?

Thanks,
Raghu
Raghavendra
Top achievements
Rank 1
 answered on 29 Dec 2011
3 answers
161 views
Hey team,

I know orgchart is a newbie to the control group and I don't see a list of things what it can do and not do. That would help instead of expecting everything from it. I saw the demo and other code from the demo section but it doesn't tell what are the limitations. For example, I see you can limit the depth of the tree but it doesn't give option to expand or drill down the tree in the org chart. Also is there way to give summary of reports for each employee on the tree. For example, manager has 3 reports which can be showed in the manager info as reports - 3. That would be good one. Also there are functional reports and HR reports in many organizations, like multiple parent scenario. 

Please let us know whats available right now and whats coming? That would help us.
Ivan Zhekov
Telerik team
 answered on 29 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?