|
Use:
Dim ddl as dropdownlist = formviewName.findcontrol("dropdownName")
if ddl is nothing then exit sub
ddl.datasource = datasource
ddl.databind
Alexei Rodriguez
modified on Monday, October 6, 2008 12:43 AM
|
|
|
|
|
Thanks for responding.
Your sample requires a datasource. However my aim is to ad items in dropdownbox one by one in back-end. Now I decided to move everything out of formview control and now facing another difficulty to bind the dropdownboxes with objectdatasource. All I want is to pass each single dropdownboxes' selected values to objectdatasource when I click the insert button. The button should initiate the following procedure.
<br />
Private Sub ObjectDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles ObjectDataSource1.Inserting<br />
<br />
Dim ParamsFromPage As IDictionary = e.InputParameters<br />
Dim NewObj As New property_availability(0, 0, 0, 0, "")<br />
<br />
NewObj.Getyear = Int32.Parse(ParamsFromPage("GetYear")).ToString<br />
NewObj.GetMonth = Int32.Parse(ParamsFromPage("GetMonth")).ToString<br />
NewObj.GetDayFrom = Int32.Parse(ParamsFromPage("GetDayFrom")).ToString<br />
NewObj.GetDayTo = Int32.Parse(ParamsFromPage("GetDayTo")).ToString<br />
NewObj.GetStatus = ParamsFromPage("GetStatus").ToString<br />
<br />
ParamsFromPage.Clear()<br />
<br />
ParamsFromPage.Add("GetYear", NewObj.Getyear)<br />
ParamsFromPage.Add("GetMonth", NewObj.GetMonth)<br />
ParamsFromPage.Add("GetDayFrom", NewObj.GetDayFrom)<br />
ParamsFromPage.Add("GetDayTo", NewObj.GetDayTo)<br />
ParamsFromPage.Add("GetStatus", NewObj.GetStatus)<br />
<br />
End Sub<br />
<br />
Do you have an idea how to do that?
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Sorry about my sample, i had the wrong datatype, i corrected it
If you are not setting the datasource and would like to add items manually, you can do it, just use the ddl.items.add
I havent used the object datasource, but what happens if you set the inputparameters?
e.inputparameters("ParamName") = dropdownlist.selectedvalue
What is all your code supposed to do??
It just reads thevalues and adds them again, am i missing something?
Alexei Rodriguez
|
|
|
|
|
Hi Alex,
Thanks for the sample. You can set input parameters in olny ObjectDataSource inserting event. However my scenerio is little bit different.
ObjectData Source is bind to Gridview and Gridview was getting populated by the formview. However I decided not to use Formview anymore because when you place a fromview inside a wizard, you won't able to get the controls' properties which are inside the formview. That is why now I am looking for a solution to somehow bind each single dropdownboxes to objectdata source, I can do that too but when you bind a dropdownbox to an objectdatasource you can't populate it in back-end coding somehow.
Anyway, I will try to integrate your sample and see if it is going to work out.
Thanks bunches for your help, I really appreciate it.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
JUNEYT wrote: However I decided not to use Formview anymore because when you place a fromview inside a wizard, you won't able to get the controls' properties which are inside the formview.
You can get the properties of the controls inside the formview
Dim ddl as dropdownlist = formviewName.findcontrol("dropdownName")
if ddl is nothing then exit sub
'you can set the datasource or any property end also add items to the dropdownlist
ddl.datasource = datasource
ddl.databind
Alexei Rodriguez
|
|
|
|
|
Thanks Alex but if I do it with the way you have indicated, I won't be able to control the events of these dropdownboxes which must be defined in aspx page.
For example, let say that I have a dropdownbox inside the formview and I want to control its OnChangeCommand="Mybox.SelectedIndexChanged".
An error occurs when you do that because it rejects not to use such definition for the dropdownbox. This problem turned in to a disaster for me.
Thanks for your help. I really much appreacited.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
JUNEYT wrote: but if I do it with the way you have indicated, I won't be able to control the events of these dropdownboxes which must be defined in aspx page
Yes you can access any event of the server control no metter if it is in the page, or inside a formview, or inside a formview which is inside another formview, it doesnt matter
To add an event to a dropdownlist, it is like with any other control
To add the default event of the control, just double click it, for the dropdownlist, the defult event is the selectedindexchanged
If you need another event, select it in the design view, in the properties window (F4) select the button that shows the events instead of the properties, select the event you want and double click it, this will generate the event in the code behind, then program your stuff as you normally would
Let me know if you are able to do it or if you have any doubts
Alexei Rodriguez
|
|
|
|
|
salam aghaye vaziri
http://www.IrExpert.ir?22439
|
|
|
|
|
The correct answers are A and C.
Why is C the correct answer and not D?
Shouldnt i set enablePasswordRetrieval = true to let the user retrieve the password?
Thanks for any comments
================================
You create a Web Form. The Web Form allows users to recover their passwords. You add a
PasswordRecovery server control by using the following code
segment.<asp:PasswordRecovery runat="server"/>You need to ensure that the server
control generates a new password and sends it by e-mail to the users e-mail address.
Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two.)
A. Create a valid <smtp> definition in the Web.config file.
B. Set the passwordFormat attribute of the configured membership provider to Encrypted.
C. Ensure that the enablePasswordRetrieval attribute of the configured membership provider is
set to False.
D. Ensure that the enablePasswordRetrieval attribute of the configured membership provider is
set to True.
Answer: A, C
Alexei Rodriguez
|
|
|
|
|
Because the question states that you need to generate and send a NEW password for the user, NOT allow them to retrieve their current one.
|
|
|
|
|
I would like to make a HttpHandler that looks for querystring and edits the image (let's say jpg) as specified. I can do all this and it works great. My issue is since every JPG is being sent to the handler what do I do if I want it to not do anything? I tried to Server.Transfer to the requested image when the querystring is 0 but that basically makes a loop. I figure I can have the handler read the file image then save it to the output stream with no edits but I don't want the server doing the extra work for nothing. Is there and easy way to do this? Is to a lot of extra work for the server to read and dispose rather than just hand the file over? Is there a better way to write the Web.config (currently I have <add verb="*" path="*.jpg" type="HTTPHandlers.PicHandler> )? Am I going about this all wrong? Thanks for any help given.
I am using ASP.NET 2.0 with VB.NET code behind.
<div class="ForumMod">modified on Sunday, October 5, 2008 12:19 PM</div>
|
|
|
|
|
well, *something* has to handle the request - if not your custom handler then .NET itself, so as long as you pass it straight back if no editing is required I wouldn't worry too much...
If [condition] Then
' amend image
...Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Else
' send original image straight to browser
context.Response.ContentType = "image/jpeg"
context.Response.WriteFile([FilePath])
End If
Otherwise, if you can separate your images into different folders such that all those that need amending are all in a particular folder then you can re-write the path="*.jpg" attribute in your web.config accordingly...
|
|
|
|
|
Can the ASP.NET cache be purged from a HttpModule? I need the code for each page to rerun after I purge certain data that I track in a HttpModule. However when I attempt to get the cache (HttpRuntime.Cache) it doesn't seem to contain anything. However, when debugging it, the code in the page does not get executed the second time through and perfmon asp.net total cache shows there are items. I am using the CommerceAD (IBuySpy.com) for my testing.
Does anyone know what is going on or how to purge this cache so that the page code will run the second time through? I would prefer to just be able to purge the cache when I need torather than disable it entirely.
Thanks.
|
|
|
|
|
Hi
Excuse me for this post, i don't found correct forum for post sharepount problem in codeProject.
Anyway, i want to add my custom calender (Persian Calender) to my sharepoint, then configure it with my calender type. at this time, when i go in User > My Setting > Regional Setting and choose Calender Type, Persian Calender does not exist in the list and i want to develop and add to calender types myself, but how to do ?
thanks
|
|
|
|
|
I have extracted controls such as text boxes, buttons, grids etc from the page and embedded them into a user control (ascx file) which is also placed on the same page! Now I'm presented with a dilemma...i'm not sure when the user clicks the button, lets say located on the page itself, I'm suppose to go inside the user controls (which is also on the same page) and make stuff happen with the controls inside this user control such as put the focus on a text box, or clear the text box's value and things like that. I have asked this question earlier, and someone told me that I can create public properties in the user control and call them from the page by using FindControl method. Well apparently this isn't working for me.
Can someone please tell me how do I use delegates to accomplish this (if possible). or if there's a better and easier way to do this kind of stuff. I'd appreciate it. Thanks
Tina
|
|
|
|
|
|
Hi friends,
I am making any saving on any web page. In code block, I am writing Response.Write(Apple.Quantity) after saving code. It turns me previous apple.quantity before recording , not current apple.quantity. How can I solve this problem?
Good Days
|
|
|
|
|
Hi,
Please paste your code and try to check if you are not initializing the value on page load.
|
|
|
|
|
Hey guys, as I mentioned in the subject line...I'm having trouble interacting between the page level controls and the User Controls (asxc files) that I have. I have devided the page into five sections
<table>
<tr> General drop downs and buttons are located here</tr>
<tr>
<td>
First User control
<td>
<td>
Second User control
</td>
</td></td></tr>
<tr>
<td>
3rd User control
</td>
<td>
4th User control
</td>
</tr>
</table>
Now ititially I wasn't using these user controls, so all the controls that are now present inside these user controls were directly located on the page. It was easier to pass into around and do things such clear the entire form and other things since all the controls were right there on the page. But now that I have extracted those controls such as text boxes, buttons, grids etc and embedded them into these user controls, I'm presented with a delliema...i'm not sure when the user clicks the button, lets say on the top level (the buttons that are located on the page itself), I'm suppose to go inside the user controls and make stuff happen such as put the focus on a text box, or clear the text box's value and things like that. I have asked this question earlier, and someone told me that I can create public properties in the user control and call them from the page by using FindControl method. Well apparently this isn;t working for me. Can someone tell me how do I use delegates to accomplish this if possible. or if there's a better and easier way to do this kind of stuff. I'd appreciate it
Tina
|
|
|
|
|
Hello!
The control is a object that is located in the page class.
that is,
you can access methods in the control by referencing them as:
Mycontrol.MyMethod() from the page.
to find buttons and/or other control in the ascx, use Mycontrol.FindControl("MyButton").
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn. What you don't know. We teach
|
|
|
|
|
Hi Andreas, thanks for the response... I actually tried something similar to this earlier...but it won't find the control when I pass in the ID of, for instance the button FindControl("MyButton").
I was reading somewher that delagates could be used to pass information around in for instance a situation like this. Can someone shed some light on this please.
Tina
|
|
|
|
|
Hi,
Use the following control to get the control rather than FindContol
public static Control GetControlByID(string id, Control ctl)
{
Control retCotl;
for (int i = 0; i < ctl.Controls.Count; i++)
{
retCotl = ctl.Controls[i].FindControl(id);
if (retCotl != null)
{
return retCotl;
}
else
{
retCotl = GetControlByID(id, ctl.Controls[i]);
if (retCotl != null)
{
return retCotl;
}
}
}
return null;
}
Some how i feel Control.FindControl is buggy and doesnot always get the control. Use this one to avoid the problem
|
|
|
|
|
Hi,
If you just need to clear textboxes and put focus on then , you can use javascript to accomplish the task i dont know why you want to clear textbox in a server side event.
If you have to call server side code use reflection to invoke method and properties of the controls.
|
|
|
|
|
hi there, thanks a lot for your response...I'm going to give it a try tomorrow. Thanks
Tina
|
|
|
|
|
php or asp.net give me good reaseon i need to know which is best for web development
|
|
|
|