Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
114 views
Cas
combobox2 changes based on combobox1. And the Rad grid will populated based on two comboboxes. when ever we change the second combobox2 selected value it shows the first value all the time and tha data in grid is not changing (combobox2 has four options date1, date2, date3 and date4. But if user changes the selection to date2 the combobox2 still shows as date1 and the data in grid is not chnaging)
please see attached code.

Thanks
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Security.Principal;
using Telerik.Web.UI;
 
public partial class _DataReview : System.Web.UI.Page
{
     
        private DataSet searchResults = new DataSet();
        private DataSet ddlist = new DataSet();
        private DataView searchResultsView = new DataView();
         
        string strID = "";
        string strcomments = "";
        string Combobox2Date = "";
 
 
        protected void Page_Load(object sender, EventArgs e)
    {
 
            if (!Page.IsPostBack)
            {
                PopulateRadCombobox1 ();
                lblErrorMsg.Visible = false;
                ViewState["Id"] = null;
 
            }
 
 
            if ((string)ViewState["Id"] != null && (string)ViewState["Id"] != "Loading...")
            {
                RadCombobox2.Text = (string)ViewState["Id"];
            }
            
            
   }
 
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            this.lblErrorMsg.Visible = false;
            string index = RadCombobox1.SelectedValue;
 
            if (index == "0" || index =="-1")
            {
                
                RadGrid1.Visible = false;
                this.lblErrorMsg.Visible = true;
                            }
            else
            {
                RadGrid1.Visible = true;
                RadGrid1.CurrentPageIndex = 0;
                RadGrid1.DataSource = this.bindGrid();
                RadGrid1.DataBind();
                btnApprove.Visible = true;
                int searchCount = RadGrid1.Items.Count;
                if (searchCount == 0)
                {
                    RadGrid1.Visible = false;
                    this.lblErrorMsg.Visible = true;
                     
                }
            }
 
        }
 
 
 
        private DataView bindGrid()
        {
             
            using (SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString))
            {
 
                string name= RadCombobox1.Text ;
                Date = RadCombobox2.Text ;
                SqlCommand cmd = new SqlCommand("dbo.SP_GetDataForRadGrid", sqlCon);
                cmd.Parameters.Add("@table_name", SqlDbType.VarChar).Value = name;
                cmd.Parameters.Add("@Date", SqlDbType.VarChar).Value = dropboxDate;
                cmd.CommandType = CommandType.StoredProcedure;
                searchResults = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(searchResults);
            }
            return searchResults.Tables[0].DefaultView;
 
        }
 
 
 
 
        private void PopulateRadCombobox1()
        {
            using (SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString))
            {
 
                try
                {
                    sqlCon.Open();
                    SqlCommand cmd = new SqlCommand("dbo.Sp_GetCombobox1data", sqlCon);
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlDataReader sqlReader = cmd.ExecuteReader();
                    if (sqlReader.HasRows)
                    {
                        RadCombobox1.DataSource = sqlReader;
                        RadCombobox1.DataTextField = "name";
                        RadCombobox1.DataValueField = "id";
                        RadCombobox1.DataBind();
                        RadCombobox1.Items.Insert(0, new RadComboBoxItem("Select Name", string.Empty));
                    }
                }
 
                catch (SqlException ex)
                {
                    lblErrorMsg.Text = ex.Message;
                    lblErrorMsg.Visible = true;
                }
                finally
                {
                    // Close the database connection
                    sqlCon.Close();
                }
 
            }
 
        }
 
        private void PopulateRadCombobox2(int ID)
        {
            using (SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString))
            {
                // RadDropBoxList.Items.Clear();
                try
                {
                    sqlCon.Open();
                    SqlCommand cmd = new SqlCommand("dbo.Sp_GetNameandLocation", sqlCon);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Id", SqlDbType.Int).Value = ID;
                    SqlDataReader sqlReader = cmd.ExecuteReader();
 
                    if (sqlReader.HasRows)
                    {
 
                        sqlReader.Read();
                        RadCombobox2.DataSource = sqlReader;
                        RadCombobox2.DataTextField = "FilePath";
                        RadCombobox2.DataValueField = "Id";
                        RadCombobox2.DataBind();
 
                    }
 
                    else if (sqlReader.HasRows == false)
                    {
                        lblDropbox.ForeColor = System.Drawing.Color.Red;
                        lblDropbox.Text = "There is No Dropboxes";
                    }
 
                }
 
                catch (SqlException ex)
                {
                    lblErrorMsg.Visible = true;
                    lblErrorMsg.Text = ex.Message;
 
                }
                finally
                {
                    // Close the database connection
                    sqlCon.Close();
                }
 
            }
 
        }
 
 
      
 
 
 
 
 
        protected void txtTitleId_TextChanged(object sender, EventArgs e)
        {
 
        }
 
 
 
            RadGrid1.CurrentPageIndex = 0;
            RadGrid1.DataSource = this.bindGrid();
            RadGrid1.DataBind();
            lblErrorMsg.Visible = true;
 
 
        }
 
 
 
 
        protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e)
        {
            RadGrid1.CurrentPageIndex = 0;
            RadGrid1.DataSource = this.bindGrid();
            RadGrid1.DataBind();
        }
 
        protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
        }
 
 
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                string Caseno = dataItem["CaseID"].Text.ToString().Trim();
                
            }
        }
 
        protected void RadGrid1_PageSizeChanged(object source, GridPageSizeChangedEventArgs e)
        {
            RadGrid1.CurrentPageIndex = 0;
            RadGrid1.DataSource = this.bindGrid();
            RadGrid1.DataBind();
        }
 
        protected void RadGrid1_SortCommand(object source, GridSortCommandEventArgs e)
        {
            RadGrid1.CurrentPageIndex = 0;
            RadGrid1.DataSource = this.bindGrid();
            RadGrid1.DataBind();
        }
 
        protected void RadCombobox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            PopulateRadCombobox1();
        }
 
 
 
        protected void RadCombobox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            // e.Text is the first parameter of the requestItems method
            string id = e.Text.ToString();
            int Id = Convert.ToInt32(id);
            PopulateRadCombobox2 (Id);
        }
 
 
 
         
}
Dimitar Terziev
Telerik team
 answered on 21 Jul 2011
1 answer
143 views
Hello,
I have used the http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx example as base of my app. I don't know how to do when doucle click in a date column to appear the datepicker to select a different date.
I have this in the UpdateValues(grid)  javascript function:
case "date":
                        HideEditor(editedCell, "textbox");
                        break;


I also added this code on the grid column:

<telerik:GridTemplateColumn UniqueName="date" SortExpression="date" AutoPostBackOnFilter="true"
                   HeaderText="DateTimeCol" HeaderStyle-Width="10%" AllowFiltering="true" DataField="date">
                   <ItemTemplate>
                       <asp:Label ID="lblDate" runat="server" Text='<%# Eval("date") %>' />
                      <telerik:RadDateTimePicker  runat="server" ID="txtDate"  DbSelectedDate='<%# Eval("date") %>'
                       Style="display: none">
                       </telerik:RadDateTimePicker  >
                   </ItemTemplate>
                   <InsertItemTemplate>
                       <telerik:RadDateTimePicker  runat="server" ID="dateInsert" Width="95%">
                       </telerik:RadDateTimePicker>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4a" runat="server" ErrorMessage="* Required Field"
                           ControlToValidate="dateInsert" BackColor="Red" BorderColor="#FF0066" BorderStyle="Solid">
                        </asp:RequiredFieldValidator>
                   </InsertItemTemplate>
                    <EditItemTemplate>
                           <telerik:RadDateTimePicker runat="server" ID="dateEdit" Width="95%"  DbSelectedDate='<%# Eval("date") %>'>
                           </telerik:RadDateTimePicker >
                           <asp:RequiredFieldValidator ID="RequiredFieldValidator4b" runat="server" ErrorMessage="* Required Field"
                            ControlToValidate="dateEdit" CssClass="error" >
                           </asp:RequiredFieldValidator>
                     </EditItemTemplate>
               </telerik:GridTemplateColumn>

Anybody knows what is the problem?
Thanks in advanced;
Jon
Genti
Telerik team
 answered on 21 Jul 2011
1 answer
131 views
http://demos.telerik.com/aspnet-ajax/grid/examples/clientbinding/defaultcs.aspx

shows a grid being bound to an oData service.  Works great but I am wondering if there is any examples of the best water to perform the insert, update and delete portion against an oData service? 
Mira
Telerik team
 answered on 21 Jul 2011
1 answer
217 views

Say I have a RadListBox, and inside the ItemTemplate for each item, I have two RadComboBox controls, a RadTextBox control, and a RadButton control.   I capture the button click in the RadButton's OnClientClicked event handler.

Inside the OnClientClicked event handler, I want to get a reference to the parent list item, so that I can I can delete that item.

For example:

function Button_OnClientClicked(button)
{
    var listBox = $find('MyListBox.ClientID');
    var itemContainingTheButtonThatWasClicked = /*  this is what I need to know    */
    listBox.get_items().remove(itemContainingTheButtonThatWasClicked);
}

Thanks
Dimitar Terziev
Telerik team
 answered on 21 Jul 2011
11 answers
186 views

Hi,

 I have a problem with the skin on sub-tabs on a RadTabStrip. The sub-items have no skin and it is impossible to see which of the sub-tabs are selected.

The same problem can be seen on this page:

http://demos.telerik.com/aspnet-ajax/tabstrip/examples/serverside/serverevents/defaultcs.aspx

I also created a small example showing the problem

<telerik:RadTabStrip ID="RadTabStrip11111" runat="server" EnableAjaxSkinRendering="true" Skin="Vista" CausesValidation="false" SelectedIndex="0" >

      <Tabs>

        <telerik:RadTab Text="aaa">

          <Tabs>

            <telerik:RadTab Text="Sub 1"></telerik:RadTab>

            <telerik:RadTab Text="Sub 2"></telerik:RadTab>

          </Tabs>

        </telerik:RadTab>

        <telerik:RadTab Text="bbb"></telerik:RadTab>

      </Tabs>

    </telerik:RadTabStrip>

 

(Version: 2009.1.408.20)

Princy
Top achievements
Rank 2
 answered on 21 Jul 2011
1 answer
50 views
I have a couple of questions about some of the functionality of the rotator when in coverflow.

1) Is there a specific property to turn on to allow the reflection?  I have set the rotatortype to coverflow but there is no reflection.

2) I have taken the code from the coverflow sample here.  But I want to add functionality such that when the user double clicks the picture that is currently being shown, then I want to show that picture in a larger image.

Thanks in advance,
Lee
Slav
Telerik team
 answered on 21 Jul 2011
0 answers
81 views
Hello! I'm having this problem (I need at the click of a button to save the file on the client side. The button is in editformsettings in Grid! 
<asp:Button ID="ButSave" runat="server" Text="Save" CommandName="SaveAnket"/> 
Grid event! 
 
void Grid_ItemCommand (object sender, GridCommandEventArgs e) 
        

                
if (e.CommandName == "SaveAnket") 
                

                    
SaveBlankOnClient (); 
                

       

 
protected void SaveBlankOnClient () 
        

            
string filename = "TextFile.txt"; 
            
string longPath = MapPath (filename); 
            
Response.ContentType = "APPLICATION / OCTET-STREAM"; 
            
string disHeader = "Attachment; Filename = \" "+ filename +" \ ""; 
            
Response.AppendHeader ("Content-Disposition", disHeader); 
            
System.IO.FileInfo fileToDownload = new System.IO.FileInfo (longPath); 
            
Response.Flush (); 
            
Response.WriteFile (longPath); 
            
Response.End (); 
        


This operation does not work for me from the grid ... But in an ordinary button, it saves the file! I understand this is due to postback? 
How save file from the GridHelp please)))
Timyr
Top achievements
Rank 1
 asked on 21 Jul 2011
1 answer
80 views
We have a data intensive application and in one particular page, we have a Rad Grid display 180 columns/10rows of data. The page works well in IE8 and takes about 10 seconds to load, but the same page takes one and a half minute to load in IE7.

We know that IE7 Javascript is slower than IE8, but the difference in rendering times between these two browsers is very high. Are there any suggestions to improve the performance in IE7?
Maria Ilieva
Telerik team
 answered on 21 Jul 2011
2 answers
749 views
Hello,

I have come across a special scenario in the web app i am developing where I need to implement custom databinding. That is i need to bind my radgrid without using its NeedDataSource Event. I want something like this (traditional ASP.NET GridView way) :
myRadGrid.DataSource= myDataSet;
myRadGrid.DataBind();
And because of this, I also need to implement custom sorting, filtering and paging. 
It will be very nice if you could post a sample app with the code implementing all of the above requirements.
Ananth Kumar
Top achievements
Rank 2
 answered on 21 Jul 2011
9 answers
344 views
Hi,

I have a Grid which has a couple of aggregated footers. They even work OK.
However, I cannot get it to display localized values. This is the markup I'm using:
<telerik:GridNumericColumn DataField="Quantity" DataType="System.Int32" UniqueName="Quantity"
    FooterAggregateFormatString="<%$ Resources:strings,strNumberOfProducts%>" Aggregate="Sum">
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Right" Width="50" />
</telerik:GridNumericColumn>
It correctly picks up the default (English) string but never picks up the localized version - although all the other parts of the grid appear localized.
I even tried to set the Culture property of the grid, but no luck.

Any idea on what I'm doing wrong?

v
Daniel
Telerik team
 answered on 21 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?