I have requirement to display a radwindow with radgrid
Scenario:
On button click a dataset will be fetched from database, I have to display the dataset as a alert to the user in grid or someother telerik tool. Can you pls provide me a solution
Thanks
5 Answers, 1 is accepted
Please have a look into the following code I tried which works fine at my end.
ASPX:
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Display Data"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
Width
=
"300px"
Height
=
"300px"
Title
=
"Employee Details"
>
<
ContentTemplate
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"true"
>
</
telerik:RadGrid
>
</
ContentTemplate
>
</
telerik:RadWindow
>
C#:
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadWindow1.VisibleOnPageLoad =
false
;
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
String connectionString = ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString"
].ConnectionString;
SqlConnection connection =
new
SqlConnection(connectionString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(
"SELECT FirstName, LastName FROM Employees"
, connection);
DataSet dataset1 =
new
DataSet();
connection.Open();
try
{
adapter.Fill(dataset1);
RadGrid1.DataSource = dataset1;
RadGrid1.DataBind();
RadWindow1.VisibleOnPageLoad =
true
;
}
finally
{
connection.Close();
}
}
Thanks,
Shinu.
Thanks Its working fine
But I have to add a OK button to close the window , it should be seperate from radgrid and it should not move when we scroll the radgrid
In order to perform RadGrid Scrolling you need to set the AllowScroll property of the RadGrid to true. By default its value is false. The ScrollHeight property specifies the height value beyond which the scrolling will be turned on. The default value is 300px. Please have a look into the updated ASPX which works as expected.
ASPX:
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Display Data"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
Width
=
"400px"
Height
=
"370px"
Title
=
"Employee Details"
>
<
ContentTemplate
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"true"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
ScrollHeight
=
"230px"
UseStaticHeaders
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
<
br
/>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
Text
=
"OK"
AutoPostBack
=
"false"
OnClientClicked
=
"closeWindow"
>
</
telerik:RadButton
>
</
ContentTemplate
>
</
telerik:RadWindow
>
Thanks,
Shinu.
Hi ,
I have a requirement, where I have to open a rad window popup with grid from one rad window popup's Yes button click event.
First I should a Radbutton , that will open a Yes or No popup, if I click yes then I should show another radwindow popup with grid data. Could you please provide any suggestion on this ?
Hi Umasankar,
Here is a basic sample that seems to fit the described scenario:
<script>
function OnClientClicked(sender, args) {
var wn = $find('<%= RadWindow1.ClientID %>');
wn.show();
}
function openGridWindow(sender, args) {
var girdWindow = $find('<%= RadWindow2.ClientID %>');
girdWindow.show();
}
function closeCurrentWindow(sender, args) {
var wn = $find('<%= RadWindow1.ClientID %>');
wn.close();
}
</script>
<telerik:RadButton runat="server" ID="RadButton1" Text="Open dialog" AutoPostBack="false" OnClientClicked="OnClientClicked" />
<telerik:RadWindow ID="RadWindow1" runat="server">
<ContentTemplate>
Open RadGrid?
<telerik:RadButton runat="server" ID="RadButton2" Text="Yes" AutoPostBack="false" OnClientClicked="openGridWindow" />
<telerik:RadButton runat="server" ID="RadButton3" Text="No" AutoPostBack="false" OnClientClicked="closeCurrentWindow" />
</ContentTemplate>
</telerik:RadWindow>
<telerik:RadWindow ID="RadWindow2" runat="server" Width="400" Top="50">
<ContentTemplate>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="300px" OnNeedDataSource="RadGrid1_NeedDataSource">
<MasterTableView AutoGenerateColumns="True" DataKeyNames="ID">
</MasterTableView>
</telerik:RadGrid>
</ContentTemplate>
</telerik:RadWindow>
C# code for binding the RadGrid
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = Enumerable.Range(1, 10).Select(x => new { ID = x, Name = "Name " + x });
}
Here are some more resources that may also prove helpful:
Kind regards,
Doncho
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.