|
Have you filled the Country DDl first in Update Form??
Then do following:
1. Run a query and get CountryID or CountryName What ever you want from Database for that perticular user. (Lets Take ID in this case)
2. write this code after getting CountryID:
int intCountryID = .....;
for(int i=0;i<(ddlCountry.Length);i++)
{
if(ddlCountry[i].Value == intCountryID)
ddlCountry.SelectedIndex = i;
}
3. Write this code into ddlCountry's SelectedIndexChanged property:
.
.
.
. here and load all cities into ddlCity
.
int intCityID = .....;
for(int j=0;j<ddlcity.length);j++)>
{
if(ddlCity[i].Value == intCityID )
ddlCity.SelectedIndex = j;
}
4. Bingo!!! Problem Solved
Got it?????????
Anand Desai
Developer
Atharva Infotech
|
|
|
|
|
Anand Desai wrote: int intCountryID = .....; // ID u got from database
for(int i=0;i<(ddlCountry.Length);i++)
{
if(ddlCountry[i].Value == intCountryID)
ddlCountry.SelectedIndex = i;
}
Just one line can do this.
ddlCountry.SelectedValue=intCountryID.ToString();
please don't forget to vote on the post that helped you.
|
|
|
|
|
That detailed code was to make Sandeep understand the basic procedure. Even I can imagine and understand what u wrote. but we have to explain all in simple language to that man. do u think Sandeep will digest as easily your line compare to my code??????????
Just wanted to teach how to think to our Juniors!!!
Anand Desai
Developer
Atharva Infotech
|
|
|
|
|
Here you will get lot of replies to your question
but i bet you are not going to learn anything as you are not showing any efforts to tackle the problem.
It seems that you are in learning phase for which you should always take help from google, there are n number of articles for developers which are in initial stage.
Please try to learn first then if you stuck with any issue (atleast put some efforts )then ask question here that's the meaning of any forum.
This is how you are going to learn
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
|
|
|
|
|
Very true.I m completely agree with u.
Anand Desai
Developer
Atharva Infotech
|
|
|
|
|
I think your update form's city dropdownlist and country dropdownlist contains list of city and country.And you want the particular city and country to come as selected.
For that by using the select query you take the value to the form.You assign that to a string variable.For example the city value is assigned to strCity and country to strCountry.If the city's dropdownlist is DropDownList1 and country's is DropDownList2.
Then you can use the following code
if (DropDownList1.Items[0].Text == strCity)
{
DropDownList1.SelectedItem.Text =strCity;
}
else
{
DropDownList1.Items.Insert(0, strCity);
}
if (DropDownList2.Items[0].Text == strCountry)
{
DropDownList2.SelectedItem.Text =strCountry;
}
else
{
DropDownList2.Items.Insert(0, strCountry);
}
Hope This Code Help You
|
|
|
|
|
i m assignning some text in a text box which is in DetailsView
in Page load event using find control
there is not any error message showing in it but text in a text box which is in DetailsView is not shown
I m giving code what i done
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim txtmachine As TextBox = New TextBox
txtmachine = CType(dvwProduct.FindControl("txtMachineId"), TextBox)
If Request.QueryString("ID") IsNot Nothing Then
txtmachine.Text = Request.QueryString.Get("ID").ToString()
Dim MachineDataSet As DataSet = New DataSet()
MachineDataSet = MachineDB.SelectMachinebyId(Request.QueryString.Get("ID").ToString())
If MachineDataSet.Tables(0).Rows.Count > 0 Then
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("txtMachineName"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("MachineName").ToString()
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("txtDescription"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("MachineShortDescription").ToString()
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("txtSpecification"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("MachineSpecification").ToString()
Dim chkmachine As CheckBox = New CheckBox()
chkmachine = CType(dvwProduct.FindControl("checkIsAvailable"), CheckBox)
chkmachine.Checked = True
' chkmachine.Text = MachineDataSet.Tables(0).Rows(0)("MachineName").ToString()
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("MachineCostCenterTextBox"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("MachineCostCenter").ToString()
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("ManPowerTextBox"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("ManPower").ToString()
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("CapecityTextBox"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("Capecity").ToString()
txtmachine = New TextBox
txtmachine = CType(dvwProduct.FindControl("ProcessNameTextBox"), TextBox)
txtmachine.Text = MachineDataSet.Tables(0).Rows(0)("ProcessName").ToString()
'MachineName()
'MachineShortDescription()
'MachineSpecification()
'checkIsAvailable()
'MachineCostCenter()
'ManPower()
'Capecity()
'ProcessName()
End If
Else
System.Web.HttpContext.Current.Session("CompanyID") = SessionData.ActiveInstance.SessionFilters("CompanyID").ToString
System.Web.HttpContext.Current.Session("DivisionID") = SessionData.ActiveInstance.SessionFilters("DivisionID").ToString
System.Web.HttpContext.Current.Session("DepartmentID") = SessionData.ActiveInstance.SessionFilters("DepartmentID").ToString
txtmachine.Text = MachineDB.ReturnId()
End If
End If
End Sub
and aspx page
]]>
<asp:content id="Content1" contentplaceholderid="_header" runat="Server" xmlns:asp="#unknown">
<asp:content id="Content2" contentplaceholderid="_lockinfo" runat="Server" xmlns:asp="#unknown">
<asp:content id="Content3" contentplaceholderid="_mainContent" runat="Server" xmlns:asp="#unknown">
<asp:detailsview id="dvwProduct" runat="server" autogeneratedeletebutton="True" autogenerateeditbutton="True">
AutoGenerateInsertButton="True" AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="objCurrProduct"
DefaultMode="Insert" HeaderText="Product Details" >
<fieldheaderstyle width="108px">
<fields>
<asp:templatefield headertext="Machine Id" sortexpression="DepartmentID">
<itemtemplate>
<asp:label id="lblMachineId" runat="server" text="<%# Eval(" machineid")="" %>"="">
<edititemtemplate>
<asp:textbox id="txtMachineId" runat="server" text="<%# Bind(" machineid")="" %>"="" width="300px">
<asp:templatefield headertext="Machine Name" sortexpression="DepartmentID">
<itemtemplate>
<asp:label id="lblMachineName" runat="server" text="<%# Eval(" machinename")="" %>"="">
<edititemtemplate>
<asp:textbox id="txtMachineName" runat="server" text="<%# Bind(" machinename")="" %>"="" width="300px">
<asp:templatefield headertext="Description" sortexpression="Title">
<itemtemplate>
<asp:label id="lblDescription" runat="server" text="<%# Eval(" machineshortdescription")="" %>"="">
<edititemtemplate>
<asp:textbox id="txtDescription" runat="server" text="<%# Bind(" machineshortdescription")="" %>"="" width="300px">
<asp:templatefield headertext="Specification" sortexpression="Description">
<itemtemplate>
<asp:label id="lblSpecification" runat="server" text="<%# Eval(" machinespecification")="" %>"="">
<edititemtemplate>
<asp:textbox id="txtSpecification" runat="server" text="<%# Bind(" machinespecification")="" %>"="" textmode="MultiLine" height="30" width="300px">
<asp:templatefield headertext="Is Available" sortexpression="SKU">
<itemtemplate>
<asp:checkbox id="checkIsAvailable" runat="server" width="300px">
<asp:templatefield headertext="Machine Cost Center" sortexpression="MachineCostCenter">
<itemtemplate>
<asp:label id="lblMachineCostCenter" runat="server" text="<%(" machinecostcenter")="" %>"="">
<edititemtemplate>
<asp:textbox id="MachineCostCenterTextBox" runat="server" text="<%# Bind(" machinecostcenter")="" %>"="" width="300px">
<asp:templatefield headertext="ManPower Used By Machine" sortexpression="ManPower">
<itemtemplate>
<asp:label id="lblManPower" runat="server" text="<%(" manpower")="" %>"="">
<edititemtemplate>
<asp:textbox id="ManPowerTextBox" runat="server" text="<%# Bind(" manpower")="" %>"="" width="300px">
<asp:templatefield headertext="Capecity Of Machine" sortexpression="Capecity">
<itemtemplate>
<asp:label id="lblCapecity" runat="server" text="<%(" capecity")="" %>"="">
<edititemtemplate>
<asp:textbox id="CapecityTextBox" runat="server" text="<%# Bind(" capecity")="" %>"="" width="300px">
<asp:templatefield headertext="Process For Machine " sortexpression="ProcessName">
<itemtemplate>
<asp:label id="lblProcessName" runat="server" text="<%(" processname")="" %>"="">
<edititemtemplate>
<asp:textbox id="ProcessNameTextBox" runat="server" text="<%# Bind(" processname")="" %>"="" width="300px">
<asp:objectdatasource id="objCurrProduct" runat="server" insertmethod="InsertProduct">
SelectMethod="SelectMachinebyId" TypeName="MachineDB" >
<selectparameters>
<asp:querystringparameter name="MachineId" querystringfield="ID">
<insertparameters>
<asp:parameter name="MachineID" type="String">
<asp:parameter name="MachineName" type="String">
<asp:parameter name="MachineShortDescription" type="String" convertemptystringtonull="false">
<asp:parameter name="MachineSpecification" type="String" convertemptystringtonull="false">
<asp:parameter name="MachineCostCenter" type="String" convertemptystringtonull="false">
<asp:parameter name="ManPower" type="int32">
<asp:parameter name="Capecity" type="int32">
<asp:parameter name="ProcessName" type="String" convertemptystringtonull="false">
<asp:sessionparameter name="CompanyID" sessionfield="CompanyID">
<asp:sessionparameter name="DivisionID" sessionfield="DivisionID">
<asp:sessionparameter name="DepartmentID" sessionfield="DepartmentID">
Raghvendra
|
|
|
|
|
Yeah.You are really in a big problem.
Debug the code and check where you are going wrong.
please don't forget to vote on the post that helped you.
|
|
|
|
|
I want to use listbox as Select ListBox.
I mean select one item from left side and add it to the other side.
I've used updatepanel for this purpose.
I have a minor problem:
in the code behind, it shows that it's doing its job correctly but the UI result is different.
and it happens irregularly.
I mean sometimes it works correctly.
Regards,
Bardia
|
|
|
|
|
|
This is the problem due to update panel.
Bardia Shahini wrote: I mean select one item from left side and add it to the other side.
How did you add items from one to another ? using any Button or ??
Bardia Shahini wrote: I've used updatepanel for this purpose.
How many update panel did you used ? if both list box are in different update panel then you should update both update panel after event fire.
if you are using button to navigate items, update both update panel on button Click, For that you have to set updatemode="Conditional" and on button click myupdatepanel.update()
hope this will helps you . if you have any dobts , then put your both Aspx and codebehind section.
cheers,
Abhijit
|
|
|
|
|
Thanks for reply,
I've used 4 buttons for transferring items from one side to the other side
MoveAll
MoveSelected
RetrunAll
ReturnSelected
and I've used a single Updatepanel.
this is my aspx code:
<updatepanel id="UpdatePanel1" runat="server" rendermode="Inline" updatemode="Conditional">
<contenttemplate>
<asp:listbox id="lstSource" runat="server" xmlns:asp="#unknown">
| <asp:button id="btnMoveAll" runat="server" text=">>" onclick="btnMoveAll_Click" xmlns:asp="#unknown">
<asp:button id="btnMoveSeleted" runat="server" text=">" onclick="btnMoveSeleted_Click" xmlns:asp="#unknown">
<asp:button id="btnRemoveSelected" runat="server" text="<" onclick="btnRemoveSelected_Click" xmlns:asp="#unknown">
<asp:button id="btnRemoveAll" runat="server" text="<<" onclick="btnRemoveAll_Click" xmlns:asp="#unknown">
| <asp:listbox id="lstDestination" runat="server" xmlns:asp="#unknown">
|
<triggers> <asp:asyncpostbacktrigger controlid="btnMoveSeleted" eventname="Click" xmlns:asp="#unknown">
<asp:asyncpostbacktrigger controlid="btnMoveAll" eventname="Click" xmlns:asp="#unknown">
<asp:asyncpostbacktrigger controlid="btnRemoveAll" eventname="Click" xmlns:asp="#unknown">
<asp:asyncpostbacktrigger controlid="btnRemoveSelected" eventname="Click" xmlns:asp="#unknown">
and this is my CodeBehind Code:
protected void btnMoveAll_Click(object sender, EventArgs e)
{
if (lstSource.Items.Count > 0)
{
int count = lstSource.Items.Count;
for (int i=0; i < count; i++)
{
lstDestination.Items.Add(lstSource.Items[i]);
}
lstSource.Items.Clear();
}
UpdatePanel1.Update();
}
protected void btnMoveSeleted_Click(object sender, EventArgs e)
{
if (lstSource.Items.Count > 0 && lstSource.SelectedValue != string.Empty)
{
lstDestination.Items.Add(lstSource.SelectedItem);
lstSource.Items.Remove(lstSource.SelectedItem);
}
UpdatePanel1.Update();
}
protected void btnRemoveSelected_Click(object sender, EventArgs e)
{
if (lstDestination.Items.Count > 0 && lstDestination.SelectedValue != string.Empty)
{
lstSource.Items.Add(lstDestination.SelectedItem);
lstDestination.Items.Remove(lstDestination.SelectedItem);
//SetListBoxIndexes();
}
UpdatePanel1.Update();
}
protected void btnRemoveAll_Click(object sender, EventArgs e)
{
if (lstDestination.Items.Count > 0)
{
int count = lstDestination.Items.Count;
for (int i=0; i < count; i++)
{
lstSource.Items.Add(lstDestination.Items[i]);
}
lstDestination.Items.Clear();
}
UpdatePanel1.Update();
}
regards,
Bardia
|
|
|
|
|
Hi guys
I am working with ajax toolkit and updating a panel that is working fine in my local system, all validations are working properly but when i am uploading this page on web server validation are firing but validation message is not displaying.
What is exact error i am not getting can any one help me
"http://www.usadigitizing.us/edit_registration.aspx["
krishna veer singh
|
|
|
|
|
krishnaveer wrote: all validations are working properly
which validation control are you using ?
cheers,
Abhijit
|
|
|
|
|
Required field Validatior
Regular Expression Validatior
Compare Validatior
krishna veer singh
|
|
|
|
|
Set Display="Static" for validation control
cheers,
Abhijit
|
|
|
|
|
Display="Static"
Validation are working Properly
and focus is also set on error text box, but error message is not displaying
krishna veer singh
|
|
|
|
|
Can you post the code for the validation control?
|
|
|
|
|
<asp:textbox id="txtPemail" runat="server" cssclass="input" maxlength="100" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" controltovalidate="txtPemail" xmlns:asp="#unknown">
ErrorMessage="*" ValidationGroup="g2" SetFocusOnError="True">
<asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" controltovalidate="txtPemail" xmlns:asp="#unknown">
ErrorMessage="Invalid email-id" Font-Italic="False" Font-Size="Smaller" SetFocusOnError="True"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="g2"
Width="70px">
krishna veer singh
|
|
|
|
|
|
Hi Gaurav,
This is called CAPTCHA stands for "completely automated public Turing test to tell computers and humans apart."
many sites use it at the time of Sign in.
if you want to implement it
Basic Image Generation For Verification[^]
For Advance
CAPTCHA Image[^]
Hope this will help you.
Good luck!!!
cheers,
Abhijit
|
|
|
|
|
hi. iam create this controls and add my webform. its work.
but when Page IsPostBack then its run again.. read resource file...
i want just one time read resource file...
can you help me?
'control class
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class MyButton
Inherits WebControls.Button
Private _translateLanguage As Boolean = True
Public Property TranstaleLanguage() As Boolean
Get
Return _translateLanguage
End Get
Set(ByVal value As Boolean)
_translateLanguage = value
End Set
End Property
Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
If TranstaleLanguage = True Then
Me.Text = Language.ResourceFile.GetString(Me.ID & "_Text")
End If
End Sub
End Class
modified on Monday, August 11, 2008 2:07 AM
|
|
|
|
|
if (Page.IsPostBack == false)
{
//your code
}
else
{
dont do anything
}
|
|
|
|
|
hi, i am create new button control and add my web form.
this control is run page preinit.
|
|
|
|
|
Hi, Im making a website with ASP.NET and C#. And in web.config I have disabled both viewstate and viewstatemac. But I still get the viewstatemac error when on a slooooow connection.
Thanks!
|
|
|
|