|
I suggest you to make one user control for Country/state selection
In that case you can accomlpish the task as
void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
switch (ddlCountry.SelectedValue)
{
case "0":
ddlState.Items.Add("Delhi");
ddlState.Items.Add("MP");
break;
case "1":
ddlState.Items.Add("Sunae");
ddlState.Items.Add("Seoul");
break;
default:
ddlState.Items.Add("Select");
break;
}
}
In case you want to continue in the same manner as you are doing then try out the following
1. Create a public variable in state.ascx.cs as
public int CountryId = 0;
2. In your function
void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
//Add lines
State objState = (State)FindControl("State1");
objState.intCountryId = ddlCountry.selectedvalue
}
3. In Page load event of state.ascx, check the value of
intCountryid and fill the dropdown accordingly.
|
|
|
|
|
1) Not a very good design to expose member variables directly
2) Not a good design either as you are tying these two controls together, one can't used without the other.
A decoupled, and more extensible and reliable design for this situation would use events to communicate between the two user controls.
only two letters away from being an asset
|
|
|
|
|
Also not a good design b/c the items being placed in the list are hard coded instead of coming from a data source. In short, yet another terrible answer given on the ASP.NET forums
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i am giving him a example, and examples are not supposed to be bind to datasource.
Now it is to the user who wants to use it and how. He may choose database or may hardcode.
I just picked lines of code from his original source
|
|
|
|
|
I am agree with Amandeep . I will bind dropdown by datasource but this is simple example. If my problem solve then I will implement though datasource.
rajesh
|
|
|
|
|
Your problem has nothing to do with the datasource and the "example" provided is a very poor example of how to design the solution.
only two letters away from being an asset
|
|
|
|
|
No you are not giving an example, you are giving a snippet. An example would be fully functional.
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: No you are not giving an example, you are giving a snippet. An example would be fully functional.
Yes, that's a snippet. What you expect from snippet, should it implement a patterns, have complete level of security with properties defined.
OR it should give a idea how you can solve a problem.
Atleast i gave a solution(poor), rather than arguing and criticizing.
|
|
|
|
|
Amandeep Singh Bhullar wrote: What you expect from snippet,
That it be accurate and useful
Amandeep Singh Bhullar wrote: Atleast i gave a solution(poor),
Check the posts, so did I, except mine was not so poorly designed.
only two letters away from being an asset
|
|
|
|
|
Is there any reason why the dropdowns are separate user controls? Doesn't really seem necessary, IMO, and is adding to your complexity.
Expose and event on the state control to be called from the country control so your sate dropdown can be populated.
only two letters away from being an asset
|
|
|
|
|
why dont you perform this opration using javascript and ajax1.1?
Anshuman Singh
|
|
|
|
|
|
Rohan Rajpoot wrote: My target is when a user checks a particular row of the datagrid,then the item in the first row and the first column(ie I have prod_id as first column in the table) should come in a label.
Did you try it or want some one else do for you ?
When select the Checbox, you will get the DataGrid index and then read the row for the corresponding Index.
cheers,
Abhijit
CodeProject.Com MVP
|
|
|
|
|
Its looks you are a new CP user and that was your fast post. I just want to say one thing , Please don't delete message. This is very rude .
cheers,
Abhijit
CodeProject.Com MVP
|
|
|
|
|
Hello There,
I have a Page on which i have a IFrame.In this Iframe I am opening a page on which i have a button.On click of that button I want to open another page in same iframe but I am not able to this.Can anybody tell me how to do this.
Thanks in advance.
|
|
|
|
|
In iFrame if there is link
<a href="a.html">link</a>
It will be opened in a iframe by default.
Can u post a sample code......
|
|
|
|
|
ais07 wrote: I want to open another page in same iframe but I am not able to this.
Why ? what problem are you facing for that ? Just Set the Target for the link . That's all !!
Hope you got my point !!
cheers,
Abhijit
CodeProject.Com MVP
|
|
|
|
|
Hi all,
when im browsing my web application ,it is showing different alignment....See,i have a form to enter data in a page.... i am able to see the form correctly in one system and whn browse frm another system only half the form is visible...wht isd wron gwtih this....
Thanks,In advance
|
|
|
|
|
Do you use any Javascript in your application?
did you try to browse on your application on first system with another web browser?
Human knowledge belongs to the world
|
|
|
|
|
There some possible reason
1. Resolution are different
2. You are not using proper CSS
3. Your controls are not placed properly on Tables .
cheers,
Abhijit
CodeProject.Com MVP
|
|
|
|
|
Hi There,
I want create tree view at runtime,where user enter parent node name and clicks on add button and parent node get created.Same is the case with child nodes.I don't know how do this.If anybody knows please help.
Thanks.
|
|
|
|
|
You can create you own scenario to add nodes to tree.
a possible and easy scenario can be this:
1-if user clicked on create root(parent) ,then you must add node to root of tree with this code:
treeView1.Nodes.add();
2-if user want to add childs, user must first select the parent node , and whenever user clicked on add child you must find current selected node and then add childs with this code:
treeNode1.ChildNodes.add();
the treeNode1 is the selected parent on treeView
Human knowledge belongs to the world
|
|
|
|
|
Thanks For Reply
I tried the same as you said.But the problem is that when i click on parent node to select, post back occures.How to prevent postback..
Thanks
|
|
|
|
|
Get a value to each nodes in tree view and whenever user select a node in selectedindexchanged event you can find TreeView1.SelectedNode.Value and then continue
Human knowledge belongs to the world
|
|
|
|
|
Hi All,
I have an ASP application in which XSL is used for creating content and menus of the page, which is working fine for IE browser.
But my client wants it to be working on Safari or Google chrome browser.
When he tries on Safari and Google chrome browsers the menus are created at the left top of the page, some sub menus are also missing and more space is created between menus and other content of the page.
Can anybody pleae help me in resolving this issue. Any links or code snippets are very much helpfull.
Thanks a Lot,
Abdul Aleem
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
modified on Monday, January 12, 2009 12:37 AM
|
|
|
|