Hi!
I have a radgrid is configured as following:
<
telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" Skin="Vista">
<MasterTableView DataKeyNames="SchematicDescriptionId"
AllowFilteringByColumn="true" AllowSorting="True" AllowCustomPaging="true" AllowPaging="True" PagerStyle-Mode="NextPrevAndNumeric" PageSize="10" CommandItemDisplay="Top" EditMode="EditForms" AllowAutomaticInserts="true" CommandItemSettings-AddNewRecordText="New Description" CommandItemSettings-RefreshText=""><Columns>.....</Columns></MasterTableView></telerik:RadGrid>
I have also a dropdownlist. Everytime I select an item in this dropdownlist, datasource of RadGrid1 will be changed. The issue is datasource comes from the 1st item of dropdownlist has 18 rows (for example) and datasource's 2nd item if dropdownlist has only 1 row. But I don't know why Paging section alway show "Displaying page 1 of 2, items 1 to 10 of 18." while the 2nd datasource just has 1 row ???
Please help me
Thank
Hung
protected
void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
this.BuildGrid();
}
protected void Page_Init(object source, System.EventArgs e)
{
}
private void BuildGrid()
{
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
boundColumn.DataField = "CountryId";
boundColumn.HeaderText = "Country Number";
this.RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn = new GridBoundColumn();
boundColumn.DataField = "CountryName";
boundColumn.HeaderText = "Country Name";
this.RadGrid1.MasterTableView.Columns.Add(boundColumn);
RadGrid1.Width = Unit.Percentage(50);
RadGrid1.PageSize = 50;
RadGrid1.AllowPaging = true;
RadGrid1.PagerStyle.Mode = Telerik.Web.UI.GridPagerMode.NextPrevNumericAndAdvanced;
RadGrid1.AutoGenerateColumns = false;
RadGrid1.ShowStatusBar = true;
RadGrid1.Skin = "Web20";
RadGrid1.ShowStatusBar = true;
RadGrid1.GridLines = GridLines.Horizontal;
RadGrid1.HorizontalAlign = HorizontalAlign.Left;
RadGrid1.ShowFooter = true;
RadGrid1.ShowHeader = true;
RadGrid1.ShowStatusBar = true;
RadGrid1.AllowSorting = true;
RadGrid1.Visible = true;
this.RadGrid1.DataSource = this.GetData();
this.RadGrid1.DataBind();
}
private DataSet GetData()
{
SqlConnection sqlConnection = new SqlConnection();
SqlCommand sqlCommand = new SqlCommand();
SqlParameter sqlParameter = new SqlParameter();
DataSet dataSet = new DataSet();
try
{
if (sqlConnection.State != ConnectionState.Open)
{
sqlConnection.ConnectionString = SqlConnectionString.GetConnectionString();
sqlConnection.Open();
}
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = ApplicationStoredProcedures.GetCountries();
sqlCommand.Parameters.Add("@WebPageName", SqlDbType.NVarChar).Value = "Authors.aspx";
sqlCommand.Parameters.Add("@CultureCode", SqlDbType.NVarChar).Value = "en-US";
sqlCommand.Parameters.Add("@ControlName", SqlDbType.NVarChar).Value = "ddlCountry";
sqlCommand.ExecuteNonQuery();
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
sqlDataAdapter.Fill(dataSet);
return dataSet;
}
catch (SqlException sql)
{
throw sql;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (sqlConnection.State != ConnectionState.Closed)
{
sqlConnection.Close();
}
sqlCommand.Dispose();
}
}
public void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
{
this.RadGrid1.CurrentPageIndex = e.NewPageIndex;
}
/// <summary>
/// You can get the exact numbers of rows in your RadGrid either directly from the DataSource or in the following manner in the ItemDataBound event:
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
Label1.Text = (e.Item as GridPagerItem).Paging.DataSourceCount.ToString();
}
}
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
// RadGrid1.DataSource = this.GetData() ;
}
I cannot find the issue. Am I doing something wrong.
<script type="text/javascript">
function Hilite(me, focus)
{
me.style.backgroundColor =
false != focus ? "#ffffcc" : "white";
}
</script>
<style type="text/css">
.ToolTipContent
{
color:black;
}
</style>
<tr>
<td class="Normal" style="padding-left:15px">Registration Start Date<font color="red">*</font></td>
<td>
<telerik:RadDatePicker ID="txtRegistrationStart" Skin="Web20" runat="server" TabIndex="6" ToolTip="Enter the date your online registrations will end.">
<DateInput ID="DateInput1" runat="server" ClientEvents-OnBlur="Hilite(this,false)" ClientEvents-OnFocus="Hilite(this)" /></telerik:RadDatePicker>
<asp:requiredfieldvalidator cssclass="Normal" controltovalidate="txtRegistrationStart" errormessage="Required." display="dynamic" runat="server" ID="Requiredfieldvalidator2"/></td></tr>
<telerik:RadToolTipManager runat="server" ID="RadToolTipManager1"
ShowEvent="OnFocus"
Skin="WebBlue"
ShowDelay="0"
AutoCloseDelay="5000"
Width="250px"
Position="MiddleRight"
RelativeTo="Element">
<TargetControls>
<telerik:ToolTipTargetControl TargetControlID="cmbSport"/>
<telerik:ToolTipTargetControl TargetControlID="txtSeasonName"/>
<telerik:ToolTipTargetControl TargetControlID="txtRegistrationStart"/>
<telerik:ToolTipTargetControl TargetControlID="txtRegistrationEnd"/>
<telerik:ToolTipTargetControl TargetControlID="txtCoachAppStart"/>
<telerik:ToolTipTargetControl TargetControlID="txtCoachAppEnd"/>
<telerik:ToolTipTargetControl TargetControlID="txtAgeAsOf"/>
</TargetControls>
</telerik:RadToolTipManager>
Thanks so much!
Susan
| <telerik:RadMenu ID="RadMenu1" runat="server" Skin="Web20" Flow="Horizontal" EnableScreenBoundaryDetection="true" | |
| EnableOverlay="true" Width="300px"> | |
| <Items> | |
| <telerik:RadMenuItem Text="Apr 15, 2008 - May 15,2008" GroupSettings-Flow="Horizontal" | |
| Width="100%"> | |
| <Items> | |
| <telerik:RadMenuItem> | |
| <ItemTemplate> | |
| <table style="height: 400px;"> | |
| <tr> | |
| <td> | |
| <telerik:RadDatePicker ID="rdpBeginDate" runat="server" Skin="Mac" Calendar-Orientation="RenderInColumns" | |
| Calendar-CellVAlign="top"> | |
| </telerik:RadDatePicker> | |
| </td> | |
| </tr> | |
| </table> | |
| </ItemTemplate> | |
| </telerik:RadMenuItem> | |
| </Items> | |
| </telerik:RadMenuItem> | |
| </Items> | |
| </telerik:RadMenu> |
<
EditItemTemplate>
<telerik:RadDateTimePicker ID="RadDateTimePicker2" runat="server" AutoPostBackControl='<%# Eval("EducationDate") %>'
Culture="English (United States)">
<DateInput InvalidStyleDuration="100">
</DateInput>
</telerik:RadDateTimePicker>
</EditItemTemplate>
error returned =
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Conversion from type 'Date' to type 'Integer' is not valid.
Source Error:
|
myGrid.PagerStyle.PagerTextFormat = Resources.
Documents.Pages_45Items;
myGrid.PagerStyle.AlwaysVisible =
true;
myGrid.PagerStyle.HorizontalAlign =
HorizontalAlign.Right;
myGrid.PagerStyle.Mode =
GridPagerMode.NextPrevNumericAndAdvanced;
myGrid.MasterTableView.TableLayout =
GridTableLayout.Fixed;
myGrid.MasterTableView.NoMasterRecordsText = Resources.
Atlas.NoItems;
myGrid.MasterTableView.NoDetailRecordsText = Resources.
Atlas.NoItems;
myGrid.MasterTableView.SortExpressions.AllowNaturalSort =
false;
myGrid.AutoGenerateColumns =
false;
myGrid.ClientSettings.Resizing.EnableRealTimeResize =
false;

| RadChart1.DataSource = Server.MapPath("~/Products.xml"); |
| RadChart1.Series[0].DataYColumn = "QuantityInStock"; |
| RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name"; |
| RadChart1.DataBind(); |
| StringBuilder sb = new StringBuilder(); |
| StringWriter sw = new StringWriter(sb); |
| XmlTextWriter writer = new XmlTextWriter(sw); |
| writer.Formatting = Formatting.Indented; |
| writer.WriteStartDocument(); |
| writer.WriteStartElement("Products", null); |
| writer.WriteStartElement("Product", null); |
| writer.WriteAttributeString("Name", "Parka L"); |
| writer.WriteAttributeString("QuantityInStock", "123"); |
| writer.WriteEndElement(); |
| writer.WriteStartElement("Product", null); |
| writer.WriteAttributeString("Name", "Parka M"); |
| writer.WriteAttributeString("QuantityInStock", "56"); |
| writer.WriteEndElement(); |
| writer.WriteStartElement("Product", null); |
| writer.WriteAttributeString("Name", "Parka S"); |
| writer.WriteAttributeString("QuantityInStock", "92"); |
| writer.WriteEndElement(); |
| writer.WriteStartElement("Product", null); |
| writer.WriteAttributeString("Name", "Mittens"); |
| writer.WriteAttributeString("QuantityInStock", "12"); |
| writer.WriteEndElement(); |
| writer.WriteEndElement(); |
| writer.Flush(); |
| XmlDocument xmlDocs = new XmlDocument(); |
| xmlDocs.LoadXml(sb.ToString()); |
| RadChart1.DataSource = xmlDocs; |
| RadChart1.Series[0].DataYColumn = "QuantityInStock"; |
| RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name"; |
| RadChart1.DataBind(); |