|
I have a checkboxlist that has values populated from a sql table's column. When i apply the selected values to a report within a page postback is triggered and the selected value seems to be lost.
how to set the selected to remain even after postback?
Appreciate your thoughts.
Thanks.
public ReadOnlyCollection<string> ParameterValues
{
get
{
this.EnsureChildControls();
List<string> names = new List<string>();
if (!string.IsNullOrEmpty(cName))
{
for (int i = 0; i < cBList.Items.Count; i++)
{
if (cBList.Items[i].Selected)
{
names.Add(cBList.Items[i].Value);
}
}
}
for (int i = 0; i < cBList.Items.Count; i++)
{
ListItem item = cBList.Items[i];
if (item.Value == cName.ToString())
{
cBList.SelectedIndex = i;
item.Selected = true;
}
}
ReadOnlyCollection<string> result = new ReadOnlyCollection<string>(names);
return result;
}
}
[ConnectionConsumer("Input Values")]
public void GetValues(ITransformableFilterValues values)
{
foreach (string val in values.ParameterValues)
{
this.Provider_Values = val;
this.Provider_Name = values.ParameterName;
ds = new SqlDataSource();
ds.ID = "Source ID";
ds.ConnectionString = cString;
ds.SelectCommand = this.SQLSelectCommand;
cBList.DataTextField = cName;
cBList.DataValueField = cName;
cBList.DataSource = ds;
cBList.ID = "List ID";
cBList.Attributes.Add("onclick", "FindSelectedItems(this," + tB.ClientID + ");");
cBList.DataBind();
}
}
|
|
|
|
|
If you data bind on postback, then your values will be lost
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
apparently now I've been staring at it for 2 days and getting the glazed look.
|
|
|
|
|
Just check whether the data bind function is inside the if(!IsPostBack) or not.
Either you love IT or leave IT...
|
|
|
|
|
Finally i was able to resolve the issue. The way i accomplished this was to create a list with the selected CheckBoxList values and reselect the original check box list based on the values in the new list.
public ReadOnlyCollection<string> ParameterValues<br />
{<br />
get<br />
{<br />
this.EnsureChildControls();<br />
<br />
List<string> names = new List<string>();<br />
if (!string.IsNullOrEmpty(cName))<br />
{<br />
for (int i = 0; i < cBList.Items.Count; i++)<br />
{<br />
if (cBList.Items[i].Selected)<br />
{<br />
names.Add(cBList.Items[i].Value);<br />
selectedCBListItems.Add(cBList.Items[i]);<br />
}<br />
}<br />
<br />
}<br />
for (int i = 0; i < cBList.Items.Count; i++)<br />
{<br />
ListItem item = cBList.Items[i];<br />
if (item.Value == cName.ToString())<br />
{<br />
cBList.SelectedIndex = i;<br />
item.Selected = true;<br />
}<br />
}<br />
ReadOnlyCollection<string> result = new ReadOnlyCollection<string>(names);<br />
return result;<br />
}<br />
}<br />
<br />
protected override void OnPreRender(EventArgs e)<br />
{<br />
base.OnPreRender(e);<br />
if (this.Page.IsPostBack)<br />
{<br />
cBList.DataBind();<br />
for (int i = 0; i < selectedCBListItems.Count; i++)<br />
{<br />
if (cBList.Items[i].Value == selectedCBListItems[i].Value)<br />
{<br />
cBList.Items[i].Selected = true;<br />
}<br />
}<br />
<br />
} <br />
}<br />
I am sure there might be some other elegant solution. I am yet to implement it. Please shed light on this topic. If you had the same issue, and if nothing else works, try the above method
|
|
|
|
|
Hi folks,
First of all, thanks for reading this question:
I have been working on a marketing tool that generates HTML based on input parameters from the URL. Now that was really easy but I have run into performance issues where I have to tweak my code to speed things up. that is good so far. However now every time I update the code, i have to ensure that the HTML is the same. Now the problem is that i have to ensure the result remains the same across 10-20 sites; and that has become my nightmare. Is there a tool that would call my aspx page with some parameters on different domains, and then company the return results to ensure the results are the same?
I thank you for reading my question and hope to hear back from you experts
Regards,
|
|
|
|
|
I have developed a website which i try to deploy on my local server(having some PCs and using one of them as server) i am not been able to get any information about the client machine i.e. machine i am using the application after deployment. Like for an example i have used the Response.IsLocal to know whether my application is really reaching to the client machine.. when i run the appliaction on server machine it returns True and on client machine it returns False... But i am not been able to create any file on client machine and not been able to get the IP of client machine.. when ever i try to create a file on client machine it creates the file on server machine and returns the IP address of Server machine. The problem is quit strange to me ... please help me out..
Thank You
|
|
|
|
|
you can not access client machine from the server, nor can you create files on the client machine.
You can use ActiveX to do that, but you will need the user's consent for that.
|
|
|
|
|
Is is possible any how i can get the client machine IP ??
or any unique no. .
I hava already tried with the activex object with java script and called the win32NetworkAdapter but it is also returning the server machine address
|
|
|
|
|
Hi to all,
I want to launch a windows application by website and also have to passed some values like username and password to the windows application.Launching the windows application is done by using process.start(without deployment) and response.redirect(after deployment)... i am also entering the username and password in my website so that the windows application should be launch for the authenticated user and i also have to pass these values(username and password) to the windows application.How can i do that???? And i have to deploy the combination of these to two on my local server.. plz help me out...
Thnxxx
|
|
|
|
|
Hmmm, that is not possible. Imagine if someone can write malicious web application that can access your local application.
If you are trying to develop Intranet application, consider using ActiveX. It has its own caveat through.
|
|
|
|
|
Hi All,
I am trying to set the value of a cookie in code-behind(vb.net) and reading it in javascript at the client side.
Jvascipt code in "Test.aspx" is :
if( readCookie("status") == "True")
setTimeout('Redirect()',1000);
function Redirect()
{
window.location = "Test.aspx";
}
But the value of the cookie is not set.
I think because I am writing the cookie via server-side script, then use a javascript
redirect, I am losing the server-side the cookie.
But, don't know how to fix it!
Can anyone help?
Thanks,
|
|
|
|
|
If all you want it redirect on timeout based on certain condition, why bother with cookies. You can write the javascript code conditionally from code behind. Look at ClientScriptManager[^] class.
|
|
|
|
|
The project is completed, it runs on local host without error.
I have written all my code based on working with this cookie. I can't change the whole now. Is there any way I can fix it with cookie?
Thanks,
|
|
|
|
|
Can you please explain more?
Thanks,
|
|
|
|
|
Hi All,
iam trying to develop a Web Server program. I wrote Server program in C# using sockets which listens to the clients. Iam trying to connect to the server through .aspx page using HttpWebRequest. If i click on send button in the web page, it is not showing the data, what i sent.
Observation: When i insert breakpoints in the server code and try to execute, it is displaying data..
Server code is like this..
class server
{
public static void main(string[] args)
{
int recv = 0;
string str;
byte[] data = new byte[1024];
IPAddress ip = IPAddress.Parse("10.18.90.110");
IPEndPoint iep = new IPEndPoint(ip, 11000);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Bind(iep);
socket.Listen(5);
Console.WriteLine("Waiting for a client..");
while (true)
{
Socket client = socket.Accept();
int recv = client .Receive(data);
string strData = Encoding.ASCII.GetString(data,0,recv);
Console.WriteLine(strData);
}
}
}
Client program..
Button_Click event
string data = "test web server";
Uri uri = new Uri("http://10.18.90.110:11000");
HttpWebRequest request = (HttpWebRequest)WebRequest.create(uri);
StreamWrite sw = new StreamWriter(request.GetRequestStream());
sw.write(data);
sw.close();
|
|
|
|
|
Under Tools, options, Project Solutions, General, there is a check box for "Prompt for symbolic renaming when renaming files". What does this do? Does it simply rename a control (e.g. button, textbox) for every instance I happen to reference the renamed control? What should happen when renaming a class file?
Thanks,
|
|
|
|
|
When starting a new project, is it recommended to store the sln and suo file within the same directory as the rest of the aspx, and cs files, or should we keep the default path under C:\Documents and Settings\<name>\My Documents\Visual Studio 2008\Projects\<websitename>?
What are the advantages/disadvantages of having the suo and sln in a different directory than the project? The reason I ask is, I'd like to transfer my whole project on a usb drive or zip, from work to home machine each night. It's hard to open all of the associated files for the solution when I go home, b/c it cannot find the sln.
Thank you
|
|
|
|
|
Well, knowing what each file does will help you make your decision.
suo: is local visual studio solution info file. It retains information as to which files are open, which project is active, windows size and location etc. You can safely delete this file and loose nothing in terms of your actual code.
sln: file is your solution file. personally I like to this hierarchy
\development\solution\project.
I stick sln in the \solution folder and my projects in the \project folder.
you are free to follow ms recommendation or come up with your own.
|
|
|
|
|
Hiall .. I have an Exception that appears sometimes in my Asp.net website. So if anyone have any idea in how can I fix this Exception please help me and I’ll be very thankful...
This is the error:
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
I’m using .Net 2005 and SQL Express Edition.
Thank u all =D
|
|
|
|
|
adigatm wrote: please help me
Why? Is the error not descriptive enough or Google [^] not working where you live?
|
|
|
|
|
adigatm wrote: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached
Errors Clearly says about the problem is related with connection pooling. What is your max pool size ? Did you handled the connection open and closed properly ?
|
|
|
|
|
Thanks for your reply.
The max pool size is 100 and I’m using the dataset wizard not coding and in the wizard I don't know if there any way to close the connection or it is closed by itself.
And the problem that is the exception is suddenly appear while the site is running.
So If you have any idea about this pleases help.
|
|
|
|
|
I want to create my own Users / admin tables with various information, and most to all articles, including both asp.net books I read all revolve around MSSQL Web Site Administration Tool, which for some reason or another I find to restrictive for my purposes.
I want to know pretty much, based on I have a registration script working, how to make a login which uses my own tables in my database. My login stored procedure compares a username and a hashed password and returns a count, 0 being obviously an inexistent or invalid combination.
So how would I go about making a login script and creating a session? If you choose to post snippets of code, VB.NET and C# is what I am capable of understanding, I'm using VS2008 and MSSQL 2005.
Just for a side question, none of the articles where all to helpful or descriptive on restricting sections of a website (or in my case, whole directories) to certain usergroups. Any detailed explanation or even pointing me to a website would be great. I don't want full code, and this is absolutely not urgent, I'm capable of waiting for an answer as there are other things to be done while waiting on this. If you took a look at all this, thanks in advance. I tried to be as descriptive as possible.
|
|
|
|
|
We all use Scheduled Tasks in Windows OS.
How to create Scheduled Tasks in dotnet code???
do u have any samples???
help me...
Thanks,
nkmkrishna.
|
|
|
|