|
I think you can get it to work, but you may need to use a page.Bind in your code behind. I haven't tried to do a for loop, but I have done if statements. So I would try a page.bind.
Ben
|
|
|
|
|
If I understand correctly Page.Bind is just like calling DataBind on every control.
There's no problem with the data source here, or data binding, it's all working fine.. I'd just like to have a for loop that goes through the row and replaces the last character in the field name with the one from the variable.
Rather than doing this:
<%# DataBinder.Eval(Container.DataItem, "somefield_a_1")%><%# DataBinder.Eval(Container.DataItem, "somefield_b_1")%><%# DataBinder.Eval(Container.DataItem, "somefield_c_1")%><%# DataBinder.Eval(Container.DataItem, "somefield_a_2")%><%# DataBinder.Eval(Container.DataItem, "somefield_b_2")%><%# DataBinder.Eval(Container.DataItem, "somefield_c_2")%><%# DataBinder.Eval(Container.DataItem, "somefield_a_3")%><%# DataBinder.Eval(Container.DataItem, "somefield_b_3")%><%# DataBinder.Eval(Container.DataItem, "somefield_c_3")%>etc.. you get the picture..
|
|
|
|
|
Actually, what I have found is without the Page.Bind the <% for loop stuff doesn't get evaluated. I guess I should say that if your code above is in a control then you can just bind the control as well.
I recently had a formview that was doing some conditional stuff with. If I didn't do the forview.databind you would see the <% if statements on the page.
So what I am saying is that Page.Bind will hopefully work for you in translating your for loop to the code above.
Ben
|
|
|
|
|
Use a Repeater control or a DataList control
only two letters away from being an asset
|
|
|
|
|
hi
i just wanted help to insert a single listbox item into the databse.
<br />
lb.Text = ListBox1.SelectedValue.ToString();<br />
cmd2.CommandText = "Insert into Bill(BillNo,PatID,Test) Values('" + maxlbl.Text + "','" + patid.Text + "','" +lb.Text+ "' ";
now, wat should be correct statement to set the label text of the listitem that is currently selected.
Kunal
|
|
|
|
|
First, you should be using stored procedures. If you can't then at least use a SqlCommand and SqlParameters.
Second, never allow unvalidated text to be inserted into your command or database.
only two letters away from being an asset
|
|
|
|
|
i know its bad programming practice, and very much prone to sql injection...
but just a mini project thing.. for some hit and trial..
Kunal
|
|
|
|
|
All the more reason to practice more correct techniques. When the deadline is near you will code what is quick and spend hours debugging and fixing afterward.
only two letters away from being an asset
|
|
|
|
|
hmm.. thats a point.. should go for the best possible practices..
cmd.Parameters.Add(); @list
now how do i pass the listbox item value into this..
Kunal
|
|
|
|
|
anyone can help ?
Server Error in '/aspx' Application.
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true">
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.Default_aspx.CreateDataView() +67
ASP.Default_aspx.Page_Load(Object sender, EventArgs e) +497
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
It is our attitude towards life and work that makes our life 100%
|
|
|
|
|
Are you trying to run an application developed in Framework 2.0? If you are, you'll have to configure your web server appropriately.
|
|
|
|
|
yes, i have installed Framework 1.1 & 2.0. Do i need to unstalled 1.1 ?
And how to configure the web server to avoid the error ?
Thanks..
It is our attitude towards life and work that makes our life 100%
|
|
|
|
|
No.
Open IIS manager, right click on virtual directory, go to properties - ASP.net tab and then select the appropriate version.
|
|
|
|
|
What makes you think it is web server configuration problem? The exception is that Sql Server can't be found?
only two letters away from being an asset
|
|
|
|
|
You are quite correct...
That'll teach me for not reading the question properly... (in my defence, it's nearly quitting time and my brain has turned to fluff...)
Sorry
|
|
|
|
|
nothingbutcat wrote: Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
Check your connection string first. If that is valid make sure the user can access it. If you are using intergated security you must make sure the ASPNET user account has been granted access to the SQL Server.
only two letters away from being an asset
|
|
|
|
|
Thank you. I start to debug from the SQL server.
It is our attitude towards life and work that makes our life 100%
|
|
|
|
|
Hi Friends,
I developed my first ajax control. it is working fine in IE6 and IE7 on my computer but not in FireFox. The more important thing and disappointing thing AJAX control is not working when I try to access from other computer. I need your help in it. I am using following code for Firefox browser in javasctipt but stil it doesn't work. Anyone of you have an idea?
// Mozilla | Netscape | Safari
objXmlHttp = new XMLHttpRequest();
Regards,
Abubakar
|
|
|
|
|
asp.net 2.0 Login control : I am getting the error When click on the login button of the login control
error message : The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current request is not over SSL.
the following line generated the error
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, True)
my WEb Config File :
authentication mode="Forms">
<forms name=".ASPXFORMSTEST" requiressl="true" loginurl="https://mysite.com/secure2/login.aspx" protection="All" path="/" timeout="60">
<rolemanager enabled="true" cacherolesincookie="true" defaultprovider="AspNetSqlRoleProvider" cookiename=".ASPXROLES" cookiepath="/" cookietimeout="30" cookierequiressl="true" cookieslidingexpiration="true" createpersistentcookie="true" cookieprotection="All">
what should i do to eliminate the error.. please help
also, the certificate is new one, so that validity is still there
|
|
|
|
|
Dear all.
i am bit new to dotnet.
i have made web application using asp.net , C# using VS2005 and sql2000 as back end .
i would like to know how to generate report using sql server 2000 reporting services.
please give me some link or example
Thanks
regards
imran khan
|
|
|
|
|
|
Hello
Please help me with the select statement for this.After the user select a projectname from the dropdowm.I want the listbox to display the name of all the member that were working under that project.
oga m
|
|
|
|
|
withou knowing the structure of your table I am writing the SQL....
SELECT member_name FROM TableName WHERE projectname='" & mycombo.Text & "'
if this is not the case please let us know your table structure...
Tirtha
"A man can ride on your back only when it is bent....."
|
|
|
|
|
you need to make master + detail
Well your problem needs more explination.
If your data is in a single table then, first you need to bind dropdownlist with the required field you can use
follwoing code or write your on code to fill the drop down list
public void BindDropDownListWithQuery(string sql, DropDownList ddl)
{
try
{
mysqlCommand = new MySqlCommand(sql);
dbConnect();
mysqlCommand.Connection = connection;
mysqlAdapter = new MySqlDataAdapter(mysqlCommand);
dataset = new DataSet();
mysqlAdapter.Fill(dataset, "Table");
ddl.DataSource = dataset.Tables[0];
ddl.DataTextField = dataset.Tables[0].Columns[0].ColumnName.ToString();
ddl.DataValueField = dataset.Tables[0].Columns[1].ColumnName.ToString();
ddl.DataBind();
}
catch (Exception)
{
connection.Close();
connection.Dispose();
}
finally
{
connection.Close();
connection.Dispose();
}
}
then you need to show Details for which you can use data grid
Now its really depend if you are filling datagrid on load event with all records then you need to filter datagrid on the basiss of value selected from dropdownlist
you can do that using this code
if (this.RadioButtonList1.SelectedIndex == 0)
{
this.odsImages.FilterExpression = "fieldname=" + this.DropDownList1.SelectedValue;
}
else if (this.RadioButtonList1.SelectedIndex == 1)
{
this.odsImages.FilterExpression = "field name=" + this.DropDownList1.SelectedValue;
}
if you are not filling datagrid onload event of web form then
you need to fill data grid with select query and you can do this using follwoing code
public void BindDataGrid(string sql, GridView GV)
{
dbConnect();
try
{
mysqlCommand = new MySqlCommand(sql);
mysqlCommand.Connection = connection;
mysqlAdapter = new MySqlDataAdapter(mysqlCommand);
dataset = new DataSet();
mysqlAdapter.Fill(dataset, "Table");
GV.DataSource = dataset;
GV.DataBind();
}
catch (Exception)
{
}
finally
{
connection.Close();
connection.Dispose();
}
}
sql="select * from tbl where fieldname=" + dropdownlist.selectedvalue;
|
|
|
|
|
Naveed Kamboh wrote: sql="select * from tbl where fieldname=" + dropdownlist.selectedvalue;
Rather lengthy response to answer the question asked.
Also, your 'solution' is far to complex for such a simple thing. Where was it mentioned in the OP that he was using a DataGrid and Radio buttons? I only see a dropdown and listbox mentioned.
only two letters away from being an asset
|
|
|
|