Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
165 views
Hey I am having a problem with a rad grid.  i am adding columns programmatically and setting a datasource in the

 

NeedDataSource event.  The problem is that i can't seem to "unlock" the checkbox column so that the user can check/uncheck the field.  what am i missing?  i can't find anything in docs describing how to do this.  i have made grid item edtible on pre render - to no effect; i have made readonly property false - also to no effect.  please help.

it is embedded in a user control like below

 

<% @ Control Language="C#" AutoEventWireup="true" CodeFile="ActiveFileTable.ascx.cs" Inherits="ActiveFileTable" %>

 

<asp:Panel ID="Panel1" runat="server" Height="531px" Width="865px">

 

<telerik:RadGrid ID="RadGrid1" runat="server">

 </telerik:RadGrid>

 

</asp:Panel>

 

 c#

 dataLayerDataContext dataLayer = new dataLayerDataContext();

RadGrid1.AutoGenerateColumns = false;

GridCheckBoxColumn boundColumn4 = new GridCheckBoxColumn();

boundColumn4.UniqueName = "Is Active";

boundColumn4.DataField = "isactive";

boundColumn4.HeaderText = "Active";

boundColumn4.Visible = true;

boundColumn4.ReadOnly = false;

 

RadGrid1.MasterTableView.Columns.Add(boundColumn4);

RadGrid1.DataSource = dataLayer.getActiveInvFilePT();

Chris
Top achievements
Rank 1
 answered on 29 Dec 2011
1 answer
78 views
Is it possible to resize an appointment while in the month view?  I am using the scheduler to show what days an employee is on a job.  These span over multiple days.  Right now I can only move the appointment around, not resize it to a certain time frame.
Richard
Top achievements
Rank 1
 answered on 29 Dec 2011
1 answer
92 views
Hi,

I am using Rad Grid and have more then 50 cells in one row. I am able to move cell one by one using arrow key or tab key but not able to move page same time, so I am able to move cells but to see those cells I have to scroll horizontal manually. I want to move page as well with moving to cell.

Also when I try to click on last cell or trying to edit that cell, automatically I am coming back to first cell.

Thanks,
Mona
Andrey
Telerik team
 answered on 29 Dec 2011
2 answers
131 views
Hi,

I have aproblem in uploading *.mht files using the Document Manager of the RadEditor control. By selecting the required *.mht file and click Upload I get the "Internet Explorer cannot display the webpage" error.

Here is my Code:
string searchPatterns = "*.doc,*.txt,*.docx,*.xls,*.xlsx,*.pdf,*.xml,*.zip,*.rar,*.mht";
CntntRadEditor.DocumentManager.SearchPatterns = searchPatterns.Split(',');

By the way, I can upload all file types except to *.mht files, and there is no maximum upload size problem (File size is 4.5 MB and the MaxUploadFileSize is 30 MB).

Can you please explain to me how can I upload such files using the Document Manager.

Regards,
Bader
Rumen
Telerik team
 answered on 29 Dec 2011
1 answer
98 views
hi everyone, i am trying to learn more about .net and teleriks control i have an easy problem but for my inexperience in this i could not to resolve, i need to save all data of my radgrid in other table, but i dont know why only save one row when i have for example 3 rows, it save only the first one i print for example the name of the product and show me 3 products so is correct the problem is when i have to save... :( .... this is my code i hope u can help me :(


Dim Connstring As String = "something"
        Dim Conn As SqlConnection = New SqlConnection(Connstring)
        Dim cmd As New SqlCommand
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "auxiliar_compra"
        cmd.Connection = Conn
        For Each dataItem As GridDataItem In RadGrid1.Items

            Try
                MsgBox(dataItem("producto").Text)
                cmd.Parameters.Add("@param1", SqlDbType.Int).Value = dataItem("cod_provee").Text
                cmd.Parameters.Add("@param2", SqlDbType.Char).Value = dataItem("proveedor").Text
                cmd.Parameters.Add("@param3", SqlDbType.Char).Value = dataItem("codigo").Text
                cmd.Parameters.Add("@param4", SqlDbType.Char).Value = dataItem("producto").Text
                cmd.Parameters.Add("@param5", SqlDbType.Decimal).Value = dataItem("unidades").Text
                cmd.Parameters.Add("@param6", SqlDbType.Money).Value = dataItem("precio").Text
                cmd.Parameters.Add("@param7", SqlDbType.Decimal).Value = dataItem("porcomprar").Text       
                cmd.Connection.Open()
                cmd.ExecuteNonQuery()
               cmd.Parameters.Clear()
            Catch ex As Exception

            End Try

        Next
cmd.Connection.Close()
Robert
Top achievements
Rank 2
 answered on 29 Dec 2011
2 answers
403 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() == "&nbsp;" || 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
51 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
70 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
80 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
97 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
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?