|
deep76 wrote: Why is my HeaderTemplate not showing up?
Place a Label/Literal control inside the HeaderTemplate and bind the Header to it. May be it would work.
|
|
|
|
|
I did place a literal inside HeaderTemplate, it appears once but the DataItem does not. Also I was expecting to see literal 'Question:' at the begenning of each new set of answers. Here is how I get my result:
Question:
Babies
Children
Teenagers
Adults
Men
Women
All of the above
Nothing
Heart
Nerves
Blood Vessels
2,3,4
Stroke
Heart disease
Hypertension
Nerve problems
Gum infection
Kidney disease
Blindness
Amputation
All of the above
Here's is how I want to see:
Question:1 Diabetes is a disease that effects:
Babies
Children
Teenagers
Adults
Men
Women
All of the above
Question:2 Increasing the amount of glucose (sugar) in blood effects:
Nothing
Heart
Nerves
Blood Vessels
2,3,4
.........
Once I get that, I will then plan on adding either radio buttons to each answer, or use a dropdown list for the user to select correct answer.
Here's my current code for repeater control:
<tr>
<td colspan="6" align="left" bgcolor="#eeeeee">
<asp:Repeater ID="repeater1" runat="server">
<headertemplate>
Question:
<%# DataBinder.Eval(Container, "DataItem.QID")%>
<%# DataBinder.Eval(Container, "DataItem.Question")%>
<br />
</headertemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container, "DataItem.Answer") %>
<br />
</ItemTemplate>
</asp:Repeater>
<asp:Label ID="lblStatus" runat="server"></asp:Label>
</td>
</tr>
|
|
|
|
|
deep76 wrote: Question:1 Diabetes is a disease that effects:
Babies
Children
Teenagers
Adults
Men
Women
All of the above
Question:2 Increasing the amount of glucose (sugar) in blood effects:
Nothing
Heart
Nerves
Blood Vessels
2,3,4
I don't think one repeater would solve this. You can solve this using Nested Repeater like,
[Repeater1 ItemTemplate]
Question 1
[Repeater2 ItemTemplate]
Shows the choices of question 1
[/Repeater2 ItemTemplate]
[/Repeater1 ItemTemplate]
Bind all the questions to the master repeater and on the ItemDataBound/DataBound event of the master repeater, load the answer of each item in the child repeater. I have tried this using DataGrid and GridView. But this should be possible in Repeater too. Lemme know if you have any questions.
Please mark it as "Good Answer" if it is useful to you.
|
|
|
|
|
Quote"
Bind all the questions to the master repeater and on the ItemDataBound/DataBound event of the master repeater, load the answer of each item in the child repeater. I have tried this using DataGrid and GridView. But this should be possible in Repeater too. Lemme know if you have any questions.
"Unquote
Can you please point to some sample code to do that. I checked several examples of repeater control on the net, none of them show how to do that.
Thank you very much for your help.
|
|
|
|
|
|
Thank You. That was helpful, but I am not there yet.
I modified my code to use nested repeater with database.
Now I get the following error where I create the relation between the questions and answers tables:
"System.ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.
Line 81: ds.Relations.Add("myrelation",
Line 82: ds.Tables["questions"].Columns["QID"],
Line 83: ds.Tables["answers"].Columns["QID"]);"
Here is my nested repeater code:
asp file:
<!-- start parent repeater -->
<asp:repeater id="parentRepeater" runat="server">
<itemtemplate>
<b><%# DataBinder.Eval(Container.DataItem,"QID") %>: </b>
<b><%# DataBinder.Eval(Container.DataItem,"Question") %></b><br>
<!-- start child repeater -->
<asp:repeater id="childRepeater" datasource='<%# ((DataRowView)Container.DataItem)
.Row.GetChildRows("myrelation") %>' runat="server">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "[\"Answer\"]")%><br>
</itemtemplate>
</asp:repeater>
<!-- end child repeater -->
</itemtemplate>
</asp:repeater>
<!-- end parent repeater -->
=========================================
axpx.cs file:
protected void CreateQuiz()
{
//Create the connection and DataAdapter for the questions table.
SqlConnection cnn = new SqlConnection(connectionString);
SqlDataAdapter cmd1 = new SqlDataAdapter("select QID, Question from Curriculum_Questions where ChapterID='2'",cnn);
//Create and fill the DataSet.
DataSet ds = new DataSet();
cmd1.Fill(ds,"questions");
//Create a second DataAdapter for the answers table.
SqlDataAdapter cmd2 = new SqlDataAdapter("select QID, Answer from Curriculum_Answers",cnn);
cmd2.Fill(ds,"answers");
//Create the relation bewtween the questions and answers tables.
ds.Relations.Add("myrelation",
ds.Tables["questions"].Columns["QID"],
ds.Tables["answers"].Columns["QID"]);
//Bind the questions table to the parent Repeater control, and call DataBind.
parentRepeater.DataSource = ds.Tables["questions"];
Page.DataBind();
//Close the connection.
cnn.Close();
}
Any clues?
Thanks.
|
|
|
|
|
deep76 wrote: "System.ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.
Line 81: ds.Relations.Add("myrelation",
Line 82: ds.Tables["questions"].Columns["QID"],
Line 83: ds.Tables["answers"].Columns["QID"]);"
This is because, you do not have a proper data in database/DataSet.
What are you trying to do?
You are literally setting up the Foreign Key relation in a DataSet.
How the data should?
Questions
QID Question
1 How are you?
2 Where are you?
3 Is my answer helpful?
Proper data
Answers
AID QID Answer
1 1 Fine
2 1 I am OK.
Invalid data
Answer
AID QID Answer
1 100 Fine
2 100 I am OK.
Make sure whatever QID you use, should available in Questions table.
I am feeling tried. I am going to bed. Will check the forum morning.
"Good luck"
|
|
|
|
|
My data seems to be fine.
Questions:
QID, Question
1 Diabetes is a disease that effects:
2 Increasing the amount of glucose (sugar) in blood effects:
3 Diabetes complications may include:
Answers:
QID, Answer
1 Babies
1 Children
1 Teenagers
1 Adults
1 Men
1 Women
1 All of the above
2 Nothing
2 Heart
2 Nerves
2 Blood Vessels
2 2,3,4
3 Stroke
3 Heart disease
3 Hypertension
3 Nerve problems
3 Gum infection
3 Kidney disease
3 Blindness
3 Amputation
3 All of the above
Sorry, I don't mean to keep you awake.
Thanks.
|
|
|
|
|
THANK YOU SO MUCH!
I found the error. I did not include chapter id constraint in my answers query, so it was fetching all the answers and therefore QIDs did not match. Now it works fine. Now I have to work on adding radio buttons / drop down list to the answers.
|
|
|
|
|
Good to hear. I believe, you would not come with RadioButton issue while using it in Repeater.
Use RadioButton's GroupName property in that case. Give a group name from each set of answers.
"Good Luck"
|
|
|
|
|
Your code:
ds.Relations.Add("myrelation",
ds.Tables["questions"].Columns["QID"],
ds.Tables["answers"].Columns["QID"]);
Change to:
ds.Relations.Add("myrelation",
ds.Tables["questions"].Columns["QID"],
ds.Tables["answers"].Columns["QID"], false);
|
|
|
|
|
Abhijit Jana wrote: eep76 wrote:
ASP.NET Tip: Using RadioButton Controls in a Repeater[^]
I tried the code from this link given by Abhijit Jana, but the code in the event handler childRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) is never reached. The radoi buttons are displayed but all are selectable.
My code copied below:
aspx:
<script type="text/javascript">
function SetUniqueRadioButton(nameregex, current)
{
re = new RegExp(nameregex);
for(i = 0; i < document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i]
if (elm.type == 'radio')
{
if (re.test(elm.name))
{
elm.checked = false;
}
}
}
current.checked = true;
}
</script>
<!-- start parent repeater -->
<asp:repeater id="parentRepeater" runat="server">
<itemtemplate>
<br><b><%# DataBinder.Eval(Container.DataItem,"QID") %>: </b>
<b><%# DataBinder.Eval(Container.DataItem,"Question") %></b><br>
<!-- start child repeater -->
<asp:repeater id="childRepeater" datasource='<%# ((DataRowView)Container.DataItem)
.Row.GetChildRows("myrelation") %>' runat="server">
<itemtemplate>
<asp:RadioButton ID="choices" runat="server" GroupName=<%# DataBinder.Eval(Container.DataItem, "[\"QID\"]")%> />
<%# DataBinder.Eval(Container.DataItem, "[\"Answer_Num\"]")%>.
<%# DataBinder.Eval(Container.DataItem, "[\"Answer\"]")%><br>
</asp:RadioButton>
</itemtemplate>
</asp:repeater>
<!-- end child repeater -->
</itemtemplate>
</asp:repeater>
<!-- end parent repeater -->
aspx.cs
protected void childRepeater_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType
!= ListItemType.AlternatingItem)
return;
RadioButton rdo = (RadioButton)e.Item.FindControl("rdoSelected");
string script =
"SetUniqueRadioButton('childRepeater.*groupName',this)";
rdo.Attributes.Add("onclick", script);
}
protected void CreateQuiz()
{
//Create the connection and DataAdapter for the questions table.
SqlConnection cnn = new SqlConnection(connectionString);
SqlDataAdapter cmd1 = new SqlDataAdapter("select QID, Question from Curriculum_Questions where ChapterID='2'",cnn);
//Create and fill the DataSet.
DataSet ds = new DataSet();
cmd1.Fill(ds,"questions");
//Create a second DataAdapter for the answers table.
SqlDataAdapter cmd2 = new SqlDataAdapter("select QID, Answer_Num, Answer from Curriculum_Answers where ChapterID='2'", cnn);
cmd2.Fill(ds,"answers");
//Create the relation bewtween the questions and answers tables.
ds.Relations.Add("myrelation",
ds.Tables["questions"].Columns["QID"],
ds.Tables["answers"].Columns["QID"]);
//Bind the questions table to the parent Repeater control, and call DataBind.
parentRepeater.DataSource = ds.Tables["questions"];
Page.DataBind();
//Close the connection.
cnn.Close();
}
Thanks for your help.
|
|
|
|
|
when i use asp.net configuration from website tab on Visual Studio 2005. i click on Security Tab i saw this message : "There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to connect to SQL Server database. "
then i select "Choose Data Store" button and select a single provider , and after that Click on test text on page. again i saw an error : "Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider. "
AnyOne know? What should i do?
[]D @ []v[] []D @ []v[]
|
|
|
|
|
pampam110 wrote: then i select "Choose Data Store" button and select a single provider , and after that Click on test text on page. again i saw an error : "Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider. "
you have to run aspnet_regsql command from command prompt and chose the database from there for web site configuration.
From Command Prompt >Goto Framework directory > Run aspnet_regsql
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql
|
|
|
|
|
Thanks Abhijit Jana. I Run aspnet_regsql . . . and i use -? for help me! but i am confused!
I find out something. first of all i havent sql express and I can't setup sql express edition. what should i do?
i have Visual Studio 2005 beta version.
Any Ideas ?!
[]D @ []v[] []D @ []v[]
|
|
|
|
|
Thanks AnyWay! my problem Solve!
[]D @ []v[] []D @ []v[]
|
|
|
|
|
Hi Pampam110,
Can you tell me how you solved your problem? I have the same one and cannot figure out what to do.
Thanks.
|
|
|
|
|
Hi
I am looking for some help from anyone who can show how I can assign a web service to named pipes. My application is a web application where the web service will be in a separate project. The design I need to implement is where the request from the client to server is one pipe where it needs to invoke a process and then down another pipe, the response, a server to client where this invokes a separate application. I am only passing XML data between the two.
In code project, I saw the two articles on NamedPipes, but being a little new to this, I could with some expert help on how to do this, and how to call the Web Service App from Asp.Net.
Can someone help me, please!
|
|
|
|
|
So you have a Web Service, a client app, and some other app on the server.
You want the client app to contact the web service, which will then activate the server app, which the client app will be waiting to hear from?
|
|
|
|
|
The client, which is an ASP.Net page or my web application, will be waiting to hear from an application, which will on another device via the web service. So, in other words browser, web application, sends XML via web service to another application else where down one pipe, does work, response from this application goes back down another pipe back to my ASP.Net page.
|
|
|
|
|
I want to display a crystal report using two tables from sql server but when report loads only header fields are visible no data is getting displayed.I have a textbox and a button on the page.After clicking on the button report should be displayed.RollNo is entered in the box and is common to both the tables.Here is the code:-
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source =SHYLOCK2E935FD7F\\SQLEXPRESS;Initial catalog=StudentDetails ;Integrated Security =true";
}
protected void btnShow_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "datasource=SHYLOCK2E935FD7F\\SQLEXPRESS;Initial catalog=StudentDetails ;Integrated Security =true";
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select c.RollNo,c.StudentName,c.Department,p.feetype,p.amount from studentheader c INNER JOIN studentdetails p on p.Rollno=c.Rollno where c.Rollno=" + TextBox1.Text + "";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
con.Close();
ReportDocument CrystalReport = new ReportDocument();
string reportPath = Server.MapPath("CrystalReport.rpt");
CrystalReport.Load(reportPath);
CrystalReport.SetDataSource(ds);
CrystalReportViewer1.ReportSource = CrystalReport;
CrystalReportViewer1.DataBind();
}
}
|
|
|
|
|
Use the stringbulder to build the string and put debug point to test wheather ur string is formed is the correct one.
for e.g
Dim sbScript as new System.Text.Stringbuilder
sbScript.append("Select eName,eSalary from Emp ")
sbScript.append("where eid=") //Use the single quote after = sign if eid is string
sbScript.append(TextBox1.Text)
cmd.CommandText = sbScript.ToString()
Hope this trick will be helpful to you...
|
|
|
|
|
I am newer to asp.net as well as to general web maker, how to implement the function for user to download one file?
I know this is quite popular function of web, but I do not know how to do it.
thanks.
|
|
|
|
|
This is one sample Example
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=MyPhoto.jpg");
Response.TransmitFile( Server.MapPath("~/images/MyPhoto.jpg") );
Response.End();
|
|
|
|
|
This is working well for images and word documents but not for any exe file
The file gets download but its not opening
|
|
|
|
|