Muralikrishna8811
Привет,
Я уже дал вам код для него вчера я думаю
вы изменили его для достижения ваших требований.
Здесь я снова посылаю весь код для него .
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language ="javascript" >
var tim;
var min = 20;
var sec = 60;
var f = new Date();
function f1() {
f2();
document.getElementById("starttime").innerHTML = "Your started your Exam at " + f.getHours() + ":" + f.getMinutes();
document.getElementById("endtime").innerHTML = "Your time is :"+f.toLocaleTimeString();
}
function f2() {
if (parseInt(sec) > 0) {
sec = parseInt(sec) - 1;
document.getElementById("showtime").innerHTML = "Your Left Time is :"+min+" Minutes ," + sec+" Seconds";
tim = setTimeout("f2()", 100);
}
else {
if (parseInt(sec) == 0) {
min = parseInt(min) - 1;
if (parseInt(min) == 0) {
clearTimeout(tim);
location.href = "default5.aspx";
}
else {
sec = 60;
document.getElementById("showtime").innerHTML = "Your Left Time is :" + min + " Minutes ," + sec + " Seconds";
tim = setTimeout("f2()", 100);
}
}
}
}
</script>
</head>
<body onload="f1()" >
<form id="form1" runat="server">
<div>
<table width="100%" align="center">
<tr>
<td colspan="2">
<h2>This is head part for showing timer and all other details</h2>
</td>
</tr>
<tr>
<td>
<div id="starttime"></div><br />
<div id="endtime"></div><br />
<div id="showtime"></div>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="DataList1" runat="server" Width ="100%"
onitemdatabound="DataList1_ItemDataBound"
>
<HeaderTemplate >
<table width="100%" align="center">
</HeaderTemplate>
<itemtemplate>
<tr>
<td>
<table width="100%" border="1" bordercolor="green" cellspacing="0" cellpadding="0">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("qid") %>'> <%#Eval("qname") %></td>
</tr>
<tr>
<td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" >
</td>
</tr>
</table>
</td>
</tr>
</itemtemplate>
<footertemplate>
</footertemplate></table>
<br />
</td>
</tr>
</table>
<br />
</div>
</form>
</body>
</html>
И код позади файла содержит следующий код
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MylocalDataClassesDataContext db = new MylocalDataClassesDataContext();
var f = from d in db.QuestionTabs
select d;
DataList1.DataSource = f;
DataList1.DataBind();
}
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
RadioButtonList rdblist = (RadioButtonList)e.Item.FindControl("RadioButtonList1");
Label lblqid = (Label)e.Item.FindControl("Label1");
string qid = lblqid.Text;
MylocalDataClassesDataContext db = new MylocalDataClassesDataContext();
var f = from d in db.QuestionTabs
where d.qid ==int.Parse (qid)
select d;
foreach (QuestionTab qt in f)
{
rdblist.Items.Add(new ListItem(qt.opt1, qt.opt1));
rdblist.Items.Add(new ListItem(qt.opt2, qt.opt2));
rdblist.Items.Add(new ListItem(qt.opt3, qt.opt3));
rdblist.Items.Add(new ListItem(qt.opt4, qt.opt4));
}
}
}
А файл базы данных-это
/****** Object: Table [dbo].[QuestionTab] Script Date: 09/22/2011 13:47:56 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QuestionTab]') AND type in (N'U'))
DROP TABLE [dbo].[QuestionTab]
GO
/****** Object: Table [dbo].[VideoTab] Script Date: 09/22/2011 13:47:56 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[VideoTab]') AND type in (N'U'))
DROP TABLE [dbo].[VideoTab]
GO
/****** Object: Table [dbo].[VideoTab] Script Date: 09/22/2011 13:47:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[VideoTab]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[VideoTab](
[vid] [int] IDENTITY(1,1) NOT NULL,
[vname] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[vpath] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_VideoTab] PRIMARY KEY CLUSTERED
(
[vid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
END
GO
SET IDENTITY_INSERT [dbo].[VideoTab] ON
INSERT [dbo].[VideoTab] ([vid], [vname], [vpath]) VALUES (1, N'video1', N'video1.swf')
INSERT [dbo].[VideoTab] ([vid], [vname], [vpath]) VALUES (2, N'video2', N'video2.swf')
INSERT [dbo].[VideoTab] ([vid], [vname], [vpath]) VALUES (3, N'video3', N'video3.wmv')
SET IDENTITY_INSERT [dbo].[VideoTab] OFF
/****** Object: Table [dbo].[QuestionTab] Script Date: 09/22/2011 13:47:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QuestionTab]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QuestionTab](
[qid] [int] IDENTITY(1,1) NOT NULL,
[qname] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[opt1] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[opt2] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[opt3] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[opt4] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ans] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_QuestionTab] PRIMARY KEY CLUSTERED
(
[qid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
END
GO
SET IDENTITY_INSERT [dbo].[QuestionTab] ON
INSERT [dbo].[QuestionTab] ([qid], [qname], [opt1], [opt2], [opt3], [opt4], [ans]) VALUES (1, N'What is CLR', N'Common language Runtime', N'cdfdfLdfdf', N'hjhjh', N'jjhjhjh', N'Common language Runtime')
INSERT [dbo].[QuestionTab] ([qid], [qname], [opt1], [opt2], [opt3], [opt4], [ans]) VALUES (2, N'WWW stands for', N'dffd', N'hghjg', N'hghg', N'World Wide Web', N'World Wide Web')
SET IDENTITY_INSERT [dbo].[QuestionTab] OFF
Попробуйте использовать приведенный выше код для вашего требования.И модифицируйте его для достижения наилучших результатов
всего наилучшего