|
I can only find 3rd party controls.
Any help would be great
thanks
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Ive got an Onclick event which has the following code in:
ViewState["items"] = lb1.SelectedItem.Value;
Response.Redirect("Page.aspx?sql=items");
on the pageload it should then display the values chosen from listbox if the page has posted back.
However when I click the Button it shows an Object Reference Error for the following line:
ViewState["items"] = lb1.SelectedItem.Value;
why is this?
thanks
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Seems to me that there there are no selected items when the button is click'ed.
if(lb1.SelectedItem != null)
{
ViewState["items"] = lb1.SelectedItem.Value;
}
If the listbox allso has multiselect = true, you will allso get a problem.
if so you should use
string strValues = "";
foreach(ListItem li in lb1.Items)
{
if(li.Selected)
{
strValuse+=li.Value;
}
}
Hope it helps
Thomas
modified on Monday, October 6, 2008 10:31 AM
|
|
|
|
|
Thanks for the post but it doesnt work Ive got
string strValues = "";
foreach (ListItem li in listbox1.Items)
{
if (li.Selected)
{
strValues += li.Value;
}
}
Session["items"] = strValues;
in the onclick event and then on pageload I have:
lbitems.Text = "Items selected: " + Session["items"].ToString();
The label is shown as blank.
I really dont understand why this is happening, very weird!
Any more help would be great
thanks
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Session is not updated at the time you go to the next page so you should us
ViewState or HttpContext.Current.Items["somevalues"]
If you have multiselect, you should splitt the valuse by somthing, so you can retrive them
Something lik:
if(listbox1.SelectedItem != null){
string strValues = "";
for (int i = 0; i < listbox1.Items.Count;i++)
{
if(listbox1.Items[i].Selected){
strValues += listbox1.Items[i].Value + ",";
}
strValues = strValues .Remove(strValues.Lenght - 1, 1);
}
HttpContext.Current.Items["theItemsValues"] = strValues;
}
on the pageload of the new page:
if(HttpContext.Current.Items.Contains("theItemsValues")) {
lbitems.Text= "Items selected: " +HttpContext.Current.Items["theItemsValues"].ToString();
}
If you then actually needs the items values:
string[] strListOfValues = HttpContext.Current.Items["theItemsValues"].ToString().Splitt(',');
modified on Tuesday, October 7, 2008 5:45 AM
|
|
|
|
|
Thanks, I will try that tomorrow and will get back to you, thnaks for the help!
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Still the problem persists.
This is one of the strangest I have ever seen. Cant understand it.
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Are you showing List item with its id and description ?
Check what is value and what is text for the list item
Try to debug the application whats happening there
Can you tell me what you have to do ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
Session["items"] = lb1.SelectedItem.Value;
Response.Redirect("Page.aspx?sql=session["items"].Tostring());
use Session state instread of Viewstate
|
|
|
|
|
Right, below is my code. It is still not working, I thought a new day would bring new answers but no.
PageLoad:
lbitems.Text = "Items selected: " + Session["items"];
Button(This posts back to the same page):
if (listbox1.SelectedItem != null)
{
string strValues = "";
for (int i = 0; i < listbox1.Items.Count - 1; i++)
{
if (listbox1.Items[i].Selected)
{
strValues += listbox1.Items[i].Value + ",";
}
}
strValues += listbox1.Items[listbox1.Items.Count - 1].Value;
Session["items"] = strValues;
}
Response.Redirect("~/main/Page.aspx?sql=items");
Why is this not working?
It doesnt display any selected values.
thanks
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
The code
strValues += listbox1.Items[listbox1.Items.Count - 1].Value;
is wrong becauce you will allways add the last item, no mather if it is selected.
I would recomand the modefide answer I gave you.
Do you redirect to the same page?
|
|
|
|
|
Hello Friend's
I get User Name from Group which created by the system but i cud not get that user from group which created by us. in other word
i get only that user which is builten(Property name of Active directory) in active directory.
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
can you put the code where you read user name from AD along with LDAP Query.
cheers,
Abhijit
Think Sharp | Code Sharp | C Sharp
|
|
|
|
|
Please provide the code den it'll be better
Cheers!!
Brij
|
|
|
|
|
hi,
i need some advice on report writing using asp.net.
currently i am using vs2005 and crystal to write them reports.
is there any other way to get the similar type of reports but using less overhead or could you tell me the best reporting tool for the web environment?
using maybe excel, asp/html????
your opinion will be appreciated...
thanks
Anoop
|
|
|
|
|
Hi
Is it possible to put html coding in stored procedure?
Like so:
select field1, field2 + ' - - ' + field3 as Fields from table
thanks
Hope this question isnt as silly as it sounds!
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Hi,
This is not a asp.net question, but if you are trying to concatenate HTML string with database column , yes you can do that
|
|
|
|
|
I need to put "<b>" in a stored procedure so that one of the columns is in bold. The reason I am doing it this way is because I am merging 2 columns into 1 and then displaying it in a listbox.
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
The answer is yes, as long as your database columns are not numeric types - if they are then you need to cast them to varchar.
create table #b1 (nme varchar(10), valuecol in)
select name + 'html codes' + convert(varchar,valuecol)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Its possible as described above, but rarely is it a good solution. Databases are for data, UI's are for presentation.
|
|
|
|
|
Hi
i want write a windows service and start it in spesific time and date but i dont know set a parameter for onstart method. can any body help me or give me a sample
|
|
|
|
|
|
can u say where should i ask?
|
|
|
|
|
Hi,
Windows services are program that runs in the background forever, however if you want to start your service at a particular time you will have to implement service controller. But i dont know why you want to do that. Just implement timer control and check for the event at which you want your windows service to do something
Regards
|
|
|
|
|
i want it start a particulat time or date . my mean is i want run it in particular time or date.
can write me a simple example about time plz. my behinde code is this:
protected override void OnStart(string[] args)
{
//TODO: Add code here to start your service.
ServiceController controller = new ServiceController();
string status = controller.Status.ToString();
eventLog1.WriteEntry("my service started");
//Start the service
controller.Start();
//Stop the service
controller.Stop();
}
and how can we trace it?
|
|
|
|