HI,
Is someone could give me explaination of this?
I have a OnSelectedIndexChanged event working properly, when I haven't set the visibility property of the grid in the aspx into false.
Then, after i set it false, why OnSelectedIndexChanged event not fired.
this is the code of my grid:
Is someone could give me explaination of this?
I have a OnSelectedIndexChanged event working properly, when I haven't set the visibility property of the grid in the aspx into false.
Then, after i set it false, why OnSelectedIndexChanged event not fired.
this is the code of my grid:
<
telerik:RadGrid
ID
=
"FacilityRadGrid"
runat
=
"server"
AllowFilteringByColumn
=
"False"
AllowMultiRowEdit
=
"False"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
PageSize
=
"10"
ShowStatusBar
=
"False"
MasterTableView-ShowFooter
=
"False"
OnNeedDataSource
=
"FacilityRadGrid_OnNeedDataSource"
OnSelectedIndexChanged
=
"FacilityRadGrid_SelectedIndexChanged"
Visible
=
"false"
>
protected
void
FacilityRadGrid_SelectedIndexChanged(
object
sender, EventArgs e)
{
//get selected row
GridDataItem item = (GridDataItem)
this
.FacilityRadGrid.SelectedItems[0];
this
.FacilityRTBId.Text = item.GetDataKeyValue(
"Record1"
).ToString();
this
.FacilityRTBName.Text = item.GetDataKeyValue(
"Record2"
).ToString();
this
.FacilitytFields.Visible =
true
;
this
.FacilityRadGrid.Visible =
false
;
}
5 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 11 Feb 2013, 12:32 PM
Hi,
I couldn't replicate the issue with the given information. Please elaborate more and provide the complete code snippet.
Thanks,
Shinu.
I couldn't replicate the issue with the given information. Please elaborate more and provide the complete code snippet.
Thanks,
Shinu.
0

David
Top achievements
Rank 1
answered on 12 Feb 2013, 01:44 AM
Hi Shinu,
this is my code:
the problem is "FacilityRadGrid_SelectedIndexChanged" doesn't fired.
if you can replicate this case, then try to remove Visible="false" from FacilityRadGrid and see what happen.
in my PC, it will wok properly if i remove that atribut, but unfortunately i need it. :(
fyi: i run in IE9, using windows 7.
Thanks.
this is my code:
the problem is "FacilityRadGrid_SelectedIndexChanged" doesn't fired.
if you can replicate this case, then try to remove Visible="false" from FacilityRadGrid and see what happen.
in my PC, it will wok properly if i remove that atribut, but unfortunately i need it. :(
fyi: i run in IE9, using windows 7.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FacilityLookup.ascx.cs"
Inherits="CCResidential.UserControl.FacilityLookup" %>
<
telerik:RadAjaxLoadingPanel
ID
=
"FacilityRadAjaxLoadingPanel"
runat
=
"server"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxPanel
ID
=
"FacilityRadAjaxPanel"
runat
=
"server"
LoadingPanelID
=
"FacilityRadAjaxLoadingPanel"
>
<
table
runat
=
"server"
id
=
"FacilitytFields"
>
<
tbody
>
<
tr
>
<
td
style
=
"width: 300px"
>
ID
</
td
>
<
td
>
:
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"FacilityRTBId"
runat
=
"server"
Enabled
=
"false"
/>
</
td
>
<
td
>
<
telerik:RadButton
ID
=
"FacilityRBSearch"
runat
=
"server"
Text
=
"Image Button"
CssClass
=
"classImage"
HoveredCssClass
=
"classHoveredImage"
PressedCssClass
=
"classPressedImage"
OnClick
=
"FacilityRBSearch_OnClick"
>
<
Image
EnableImageButton
=
"true"
/>
</
telerik:RadButton
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Name
</
td
>
<
td
>
:
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"FacilityRTBName"
runat
=
"server"
Enabled
=
"false"
/>
</
td
>
</
tr
>
</
tbody
>
</
table
>
<
telerik:RadGrid
ID
=
"FacilityRadGrid"
runat
=
"server"
AllowFilteringByColumn
=
"False"
AllowMultiRowEdit
=
"False"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
PageSize
=
"10"
ShowStatusBar
=
"False"
MasterTableView-ShowFooter
=
"False"
OnNeedDataSource
=
"FacilityRadGrid_OnNeedDataSource"
OnSelectedIndexChanged
=
"FacilityRadGrid_SelectedIndexChanged"
Visible
=
"false"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
ExportSettings
IgnorePaging
=
"true"
/>
<
MasterTableView
DataKeyNames
=
"Record1,Record2"
EditMode
=
"PopUp"
HorizontalAlign
=
"NotSet"
Width
=
"100%"
CommandItemDisplay
=
"None"
OverrideDataSourceControlSorting
=
"true"
>
<
CommandItemSettings
ShowExportToCsvButton
=
"false"
ShowAddNewRecordButton
=
"false"
ExportToCsvImageUrl
=
"~/Images/export.gif"
ShowRefreshButton
=
"false"
/>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
Visible
=
"True"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
Visible
=
"True"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridButtonColumn
CommandName
=
"Select"
Text
=
"Select"
UniqueName
=
"Select"
/>
<
telerik:GridBoundColumn
HeaderText
=
"ID"
DataField
=
"Record1"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Type"
DataField
=
"Record2"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Name"
DataField
=
"Record3"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
telerik:RadAjaxPanel
>
using
System;
using
System.Collections.Generic;
using
CCResidential.Entity;
using
Telerik.Web.UI;
namespace
CCResidential.UserControl
{
/// <summary>
/// Facility User Control
/// </summary>
public
partial
class
FacilityLookup : System.Web.UI.UserControl
{
private
List<CommonRecord> _commonRecords;
/// <summary>
/// Initializes a new instance of the <see cref="FacilityLookup"/> class.
/// </summary>
public
FacilityLookup()
{
this
._commonRecords =
new
List<CommonRecord>();
CommonRecord commonRecord =
new
CommonRecord();
commonRecord.Record1 =
"32136820"
;
commonRecord.Record2 =
"Luxurious Old Man House"
;
commonRecord.Record3 =
"Pasar Kliwon"
;
this
._commonRecords.Add(commonRecord);
commonRecord =
new
CommonRecord();
commonRecord.Record1 =
"32136845"
;
commonRecord.Record2 =
"The Australian Home"
;
commonRecord.Record3 =
"2 Holt Street, Surry Hills,NSW, 2010, Australia"
;
this
._commonRecords.Add(commonRecord);
commonRecord =
new
CommonRecord();
commonRecord.Record1 =
"32136898"
;
commonRecord.Record2 =
"Home of Peace"
;
commonRecord.Record3 =
"Niels Bohrs Alle 23, 1330"
;
this
._commonRecords.Add(commonRecord);
}
/// <summary>
/// Handles the Load event of the Page control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
this
.FacilityRadGrid.Visible =
false
;
}
}
/// <summary>
/// Handles the OnClick event of the RBSearch control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected
void
FacilityRBSearch_OnClick(
object
sender, EventArgs e)
{
this
.FacilitytFields.Visible =
false
;
this
.FacilityRadGrid.Visible =
true
;
this
.FacilityRadGrid.Rebind();
}
/// <summary>
/// Handles the OnNeedDataSource event of the RGResident control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected
void
FacilityRadGrid_OnNeedDataSource(
object
sender, EventArgs e)
{
this
.FacilityRadGrid.DataSource =
this
._commonRecords;
}
/// <summary>
/// Handles the SelectedIndexChanged event of the RGResident control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected
void
FacilityRadGrid_SelectedIndexChanged(
object
sender, EventArgs e)
{
//get selected row
GridDataItem item = (GridDataItem)
this
.FacilityRadGrid.SelectedItems[0];
this
.FacilityRTBId.Text = item.GetDataKeyValue(
"Record1"
).ToString();
this
.FacilityRTBName.Text = item.GetDataKeyValue(
"Record2"
).ToString();
this
.FacilitytFields.Visible =
true
;
this
.FacilityRadGrid.Visible =
false
;
}
}
}
Thanks.
0
Hello David,
If the grid has its Visible property set to false, it won't be rendred whatsover. So, how do you trigger the selected index changed event in that case? Please, elaborate.
Regards, Tsvetoslav
the Telerik team
If the grid has its Visible property set to false, it won't be rendred whatsover. So, how do you trigger the selected index changed event in that case? Please, elaborate.
Regards, Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

David
Top achievements
Rank 1
answered on 15 Feb 2013, 12:33 AM
hi,
sorry didn't write down the scenario clearly. what i want is some scenario like this:
1. all field appear (FacilitytFields.visible = true), but grid should be hide (FacilityRadGrid.visible = false).
2. when i click the button (FacilityRBSearch), i do the FacilityRBSearch_OnClick area which is all field hide(FacilitytFields.visible = false), but grid should be appear(FacilityRadGrid.visible = true).
note that after I update the visibility of the grid, i also do Rebind().
3. I select a row in the grid bu clicking the GridButtonColumn
4. then In this step, i expect i should be i enter the FacilityRadGrid_SelectedIndexChanged area to get a values and set it into the textBoxes.
Step 4 run normally when I haven't hided the grid in the fisrt time. what I need is the way to make SelectedIndexChanged run in those case.
sorry didn't write down the scenario clearly. what i want is some scenario like this:
1. all field appear (FacilitytFields.visible = true), but grid should be hide (FacilityRadGrid.visible = false).
2. when i click the button (FacilityRBSearch), i do the FacilityRBSearch_OnClick area which is all field hide(FacilitytFields.visible = false), but grid should be appear(FacilityRadGrid.visible = true).
note that after I update the visibility of the grid, i also do Rebind().
3. I select a row in the grid bu clicking the GridButtonColumn
.4. then In this step, i expect i should be i enter the FacilityRadGrid_SelectedIndexChanged area to get a values and set it into the textBoxes.
Step 4 run normally when I haven't hided the grid in the fisrt time. what I need is the way to make SelectedIndexChanged run in those case.
0

Shinu
Top achievements
Rank 2
answered on 15 Feb 2013, 04:56 AM
Hi,
Try removing the RadGrid property Visible from the ASPX as you have set it in code behind. Also try removing the OnSelectedIndexChanged event from code behind and from design mode and generate it again .
Thanks,
Shinu.
Try removing the RadGrid property Visible from the ASPX as you have set it in code behind. Also try removing the OnSelectedIndexChanged event from code behind and from design mode and generate it again .
Thanks,
Shinu.