|
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
|
|
|
|
|
4anusha4 wrote: This is working well for images and word documents but not for any exe file
Obviously that code will not work for exe, that was only for image. Becuase for for exe you have to chnage the content type.
Response.ContentType = "application/exe";
|
|
|
|
|
if (e.CommandName == "download") {
Response.ContentType = "jpeg/doc/exe/jif";
Response.AppendHeader("Content-Disposition", "attachment; filename='" + sfileName + "'");
Response.TransmitFile(Server.MapPath("~/files/" + sfileName));
Response.End();
lblStatus.Text = "File is Downloaded";
}
i used like this
|
|
|
|
|
Great !
|
|
|
|
|
thanks a lot!
I found that you wrote several very useful articles, it is nice of you!
I just start learning ASP.net, hopefully, I can receive more help from you in the future!
|
|
|
|
|
You are welcome
|
|
|
|
|
I googled and googled and I'm all googled out...I can't find anything useful.
How can I add MIME types to my web setup project (i.e. Silverlight MIME types) so that it doesn't have to be added manually after the install?
|
|
|
|
|
Dear All,
I am using XP SP2 os in my pc.
I installed SQL server 2000.
and Created a Virtual directory for my deployed website.
the website runs on deplyoed mode but when i try to access database of sql server it gives an errr 'Login Failed to ABC/ASPNET user'.
i also installed VS2005 and in debug mode my wite is working fine.
what i do for it???...
In enterprise server it shows two server group Local(Windows) and ABC-SQL EXPRESS 2005. here i can access only local server group.
is it try to connect sql server 2005 Express at the time of deplyoed environment???
|
|
|
|
|
check SQL Server password.. is it correct??
|
|
|
|
|
Hello everyone.
I created a page in which user can upload images and delete as well. But the problem is if user uploads an image(fine)..n hits f5 then same image is again uploaded..which means on refreshing the upload event starts. I tried it by putting condition on upload button event !page.postback..but then user is unable to upload @ all..how i fix tis problem..
*thnx*
|
|
|
|
|
After uploading you clear the value of file upload control.....
In UI part hope so validation should be there in such a way that it should not allow user to upload file before selecting
|
|
|
|
|
Ok bt what about..delete controls and sending a message same problem i face there 2..
|
|
|
|