I have a form in which i am using dataGrid to acess the data from the database.
Now on clicking the button a new Detailview page is open in which i want to retrieve value according to the button in which click.
My Default.aspx coding is
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
function OpenPopUp()
{
window.showModalDialog("child.aspx", ' ', 'dialogHeight:10;
dialogWidth: 300px; dialogTop: 125px; dialogLeft: 100px; edge: Raised;
center: Yes; resizable: No; status: Yes;');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
<telerik:RadGrid ID="RadGrid1" runat="server"
AllowFilteringByColumn="True"
OnNeedDataSource="RadGrid1_NeedDataSource" GridLines="None"
Height="750px" AllowSorting="True" PageSize="8" AllowPaging="True">
<MasterTableView AllowMultiColumnSorting="True" AutoGenerateColumns="False">
<Columns>
<telerik:GridBoundColumn UniqueName="CITY_CODE" DataField="CITY_CODE" HeaderText="City Code" >
<HeaderStyle Width="200px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="NAME" DataField="NAME" HeaderText="Hotel Name" >
<HeaderStyle Width="200px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ADDRESS_3" DataField="ADDRESS_3" HeaderText="City" >
<HeaderStyle Width="200px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="PHONE" DataField="PHONE" HeaderText="Phone Number" >
<HeaderStyle Width="200px" />
</telerik:GridBoundColumn>
</Columns>
<ItemTemplate>
<%# (((GridItem)Container).ItemIndex != 0) ?
"</td></tr></table>" :
"</td></tr></table>"%>
<asp:Panel ID="ItemContainer" CssClass='<%#
(((GridItem)Container).ItemType == GridItemType.Item)? "item" :
"alternatingItem" %>'
runat="server" Width="326px" Height="122px">
<asp:Label ID="titleLabel" runat="server" Text="City Code:"
Font-Bold="true" style="float:left;width:30%;text-align:right"/>
<asp:Label ID="lblCityCode" runat="server" Text='<%# Eval("CITY_CODE") %>'/><br />
<asp:Label ID="Label6" runat="server" Text="Hotel Name:"
Font-Bold="true" style="float:left;width:30%;text-align:right"/>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("NAME") %>'/><br />
<asp:Label ID="Label7" runat="server" Text="Address:"
Font-Bold="true"
style="float:left;width:30%;text-align:right"/>
<asp:Label ID="lblAddress"
runat="server" Text='<%# Eval("ADDRESS_1")+ ", " %>' /><br
/>
<asp:Label ID="Label8" runat="server"
style="float:left;width:30%;text-align:right"/>
<asp:Label ID="lblAddress2"
runat="server" Text='<%# Eval("ADDRESS_2")+ ", " %>' /><br
/>
<asp:Label ID="Label9" runat="server" style="float:left;width:30%;text-align:right"/>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("ADDRESS_3")+ ", " %>' /><br />
<asp:Label ID="Label10" runat="server" style="float:left;width:30%;text-align:right"/>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("ADDRESS_4") %>' /><br />
<asp:Label ID="Label11" runat="server" Text="Phone Number:"
Font-Bold="true" style="float:left;width:30%;text-align:right"/>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("PHONE") %>'/><br />
<asp:Label ID="Label12" runat="server" Text="Fax:" Font-Bold="true"
style="float:left;width:30%;text-align:right"/>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("FAX") %>'/>
<br />
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
<button style="width: 40px; margin-bottom: 3px;"
onclick="OpenPopUp()">More</button><br style="clear:both"
/><br style="clear:both" />
</asp:Panel>
</ItemTemplate>
</MasterTableView>
<GroupingSettings CaseSensitive="False" />
</telerik:RadGrid>
</form>
</body>
</html>
default.aspx.cs is
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlConnection = new SqlConnection("Data Source =
DELLVOSTRO; Initial Catalog = ALPHA; User Id= sa; Password= intransit");
string selectString = "SELECT CITY_CODE,NAME,PHONE,ADDRESS_1,ADDRESS_2,ADDRESS_3,ADDRESS_4,FAX " + "FROM HOTELS ";
SqlDataAdapter dataAdapter = new SqlDataAdapter(selectString, sqlConnection);
DataTable table = new DataTable();
dataAdapter.Fill(table);
RadGrid1.DataSource = table;
RadGrid1.DataBind();
}
child.aspxis
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="child.aspx.cs" Inherits="child" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Message Deatils</title>
</head>
<body>
<script type="text/javascript">
function GetRadWindow()
{
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)
return oWindow;
}
function CloseWnd()
{
GetRadWindow().close();
}
function OnClientLoad(sender,args)
{
window.setTimeout(function()
{
sender.set_mode(2);
sender.set_mode(1);
}, 0);
}
</script>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadSkinManager ID="RadSkinManager" runat="server" Skin="Outlook">
</telerik:RadSkinManager>
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
LoadingPanelID="RadLoadingPanel1">
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" Width="33%"
CellPadding="0" Height="100%" GridLines="None" OnPageIndexChanging="DetailsView1_PageIndexChanging">
<Fields>
<asp:BoundField DataField="CITY_CODE" HeaderText="City Code:" SortExpression="CITY_CODE" >
<HeaderStyle Width="30%" />
</asp:BoundField>
<asp:BoundField DataField="NAME" HeaderText="Hotel Name:" SortExpression="NAME" />
<asp:BoundField DataField="ADDRESS_1" HeaderText="ADDRESS:" SortExpression="NAME" />
<asp:BoundField DataField="ADDRESS_2" SortExpression="NAME" />
<asp:BoundField DataField="ADDRESS_3" SortExpression="NAME" />
<asp:BoundField DataField="ADDRESS_4" SortExpression="NAME" />
<asp:BoundField DataField="PHONE" HeaderText="Phone Number" SortExpression="NAME" />
<asp:BoundField DataField="FAX" HeaderText="Fax" SortExpression="NAME" />
</Fields>
</asp:DetailsView>
<div style="text-align: right; margin-top:8px;">
</div>
</telerik:RadAjaxPanel>
<telerik:RadAjaxLoadingPanel ID="RadLoadingPanel1" runat="server" >
</telerik:RadAjaxLoadingPanel>
</form>
</body>
</html>
child.aspx.cs is
public partial class child : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlConnection = new SqlConnection("Data Source =
DELLVOSTRO; Initial Catalog = ALPHA; User Id= sa; Password= intransit");
string selectString = "SELECT
CITY_CODE,NAME,PHONE,ADDRESS_1,ADDRESS_2,ADDRESS_3,ADDRESS_4,FAX " +
"FROM HOTELS "+ "Where FAX = '"+label3.text+"'";
SqlDataAdapter dataAdapter = new SqlDataAdapter(selectString, sqlConnection);
DataTable table = new DataTable();
dataAdapter.Fill(table);
DetailsView1.DataSource = table;
DetailsView1.DataBind();
}
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
{
}
}