|
No, that will not help.
In fact, it will prevent you from submiting the data on the first attempt if it is enclosed by the if "(!IsPostBack".
|
|
|
|
|
Hello to all,
I'm working on a MVC 2 project. I have a View with some search fields. User can select his search criteria and based on that criteria, the records are displayed on the View. After that, the user can click a button to edit the record that he chosen. The user is redirect to the edit page. There he have the details of that record and can edit it. After save the changes, the user have a back button, that returns to the search page and results. And here is the problem. When I go back to the search page, the search criteria that I have selectd has gone. I need to fill the search fields again. I tried TempData, ViewData, ViewBag, Session and nothing.
Can you help me please?
|
|
|
|
|
I think most of your solutions should do the trick, however I would opt in using session. Can I ask how did you try to use it? For example, does your search criteria exist in model and do you fill it on GET action?
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
The Session attributes should work. Perhaps if you could post your code here, it may help further.
|
|
|
|
|
Hi Team, i have a master page in my .net application and from master page i call a helper file (.cs)and my requirement is i would like to execute one method(returns a string value) in that helper file, my application connects to master page each time upon loading of different pages i would like to keep the first method call value and persist the value between different page calls
i am unable to user httpcontext.session object as it gives me null values always ,
can some one suggest me the best way to preserve the method call value between round trips.i cannot use caching also as pages may change per user hence user caching cannot be applied here.
|
|
|
|
|
Dear developers,
In my view, the best way to study ASP.NET is to run the ASP.NET examples. Therefore I want to ask a question about remote debugging ASP.NET Applications. Recently, I have
read a very interesting article on the link
http://www.codeproject.com/Articles/38132/Remote-IIS-Debugging-Debug-your-ASP-NET-Applicatio
If I have understood correctly, one of necessary conditions to use this possibility is to
have a Visual Studio on any local computer (see "Fig: Block Diagram for Remote debugging of ASP.NET Application" from this article). In my understanding, If I have the local Visual Studio then I can debug my application on my computer always. My question is the following: How one can debug an ASP.NET Application on remote computer without any local Visual Studio ? This question is very important for me to get any positive answer. Suppose, a beginner wants to study ASP.NET by running the examples from a Tutorial about ASP.NET. But the beginner doesn't have any Visual Studio on his computer.
Gennady
modified 9-Oct-13 10:14am.
|
|
|
|
|
Usually part of tutorial is changing parts of example application and see the results. To be able to do this you need at tool that allows you to rebuild application after changes - the Visual Studio.
Visual Studio Express products are free and more than enough for any tutorial example, so why not?
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
i have a dropdown in my page this is use for State and i have bound state list in dropdown but when submit form then error msg show "'drpCrntState' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value"
tripat bala singh
|
|
|
|
|
Show your code
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
if (btnSave.Text == "Save")
{
BOStudentDetails ObjStudent = new BOStudentDetails();
ObjStudent.SchoolID = Convert.ToInt32(drpSchool.SelectedValue);
ObjStudent.ClassID = Convert.ToInt32(drpClass.SelectedValue);
ObjStudent.StudentName = txtStudentFname.Text+ ' ' + txtStudentMname.Text + ' ' + txtStudentLname.Text;
//ObjStudent.StudentPhoto = "fsdfs";
ObjStudent.StudentDob = txtdob.Text;
ObjStudent.StudentAddmissionDate = txtAdmissionDate.Text;
ObjStudent.StudentFthName = txtFthName.Text;
ObjStudent.StudentMthName = txtMthName.Text;
ObjStudent.StudentCategory = Convert.ToString(drpCategory.SelectedItem);
ObjStudent.StudentGender = Convert.ToString(drpGender.SelectedItem);
ObjStudent.StudentMobile1 = txtMobile1.Text;
ObjStudent.StudentMobile2 = txtMobile2.Text;
ObjStudent.StudentLandline = txtLandlinePhon.Text;
ObjStudent.StudentDiscription = txtDiscription.Text;
ObjStudent.StudentPrmAdd = txtPrmAdd.Text;
ObjStudent.StudentPrmState =Convert.ToString(drpPrmState.SelectedItem);
ObjStudent.StudentPrmCity = Convert.ToString(drpPrmCity.SelectedItem);
ObjStudent.StudentPrmLocation = Convert.ToString(drpPrmLocation.SelectedItem);
ObjStudent.StudentPrmPin = txtPrmPin.Text;
ObjStudent.StudentCrntAdd = txtCrntAdd.Text;
ObjStudent.StudentCrntState = Convert.ToString(drpCrntState.SelectedItem);
ObjStudent.StudentCrntCity = Convert.ToString(drpCrntCity.SelectedItem);
ObjStudent.StudentCrntLocation = Convert.ToString(drpCrntLocation.SelectedItem);
ObjStudent.StudentCrntPin = txtCrntPin.Text;
if (flupldStdPhoto.HasFile)
{
string StudentExtension = Path.GetExtension(flupldStdPhoto.FileName);
if (!StudentExtension.ToLower().Equals(".gif")
&& !StudentExtension.ToLower().Equals(".jpg")
&& !StudentExtension.ToLower().Equals(".jpeg"))
{
Functions.MsgBox("Director's sign is not in correct format." +
System.Environment.NewLine +
"Signature sign should be gif or jpg or jpeg image.");
return;
}
flupldStdPhoto.SaveAs(Server.MapPath("~/Admin/Student Photo/") + flupldStdPhoto.FileName);
ObjStudent.StudentPhoto = flupldStdPhoto.FileName;
}
balStudentObj.InsertStudent(ObjStudent);
Clear();
ShowAlert(this.Page, "Record inserted successfully");
}
else if(btnSave.Text=="Update")
{
}
}
catch
{
}
}
DAL
----------------
public void InsertSchools(BOStudentDetails ObjStudent)
{
SqlParameter[] paramList =
{
new SqlParameter("@SchoolId",ObjStudent.SchoolID),
new SqlParameter("@ClassId",ObjStudent.ClassID),
new SqlParameter("@StName",ObjStudent.StudentName),
new SqlParameter("@StDob", ObjStudent.StudentDob),
new SqlParameter("@StAdmDate", ObjStudent.StudentAddmissionDate),
new SqlParameter("@StFthName", ObjStudent.StudentFthName),
new SqlParameter("@StMthName", ObjStudent.StudentMthName),
new SqlParameter("@StCat", ObjStudent.StudentCategory),
new SqlParameter("@StGender", ObjStudent.StudentGender),
new SqlParameter("@StMob1", ObjStudent.StudentMobile1),
new SqlParameter("@StMob2", ObjStudent.StudentMobile2),
new SqlParameter("@StLandline", ObjStudent.StudentLandline),
new SqlParameter("@StDiscription", ObjStudent.StudentDiscription),
new SqlParameter("@StprmAdd", ObjStudent.StudentPrmAdd),
new SqlParameter("@StprmState", ObjStudent.StudentPrmState),
new SqlParameter("@StprmCity", ObjStudent.StudentPrmCity),
new SqlParameter("@StprmLoc", ObjStudent.StudentPrmLocation),
new SqlParameter("@StprmPin", ObjStudent.StudentPrmPin),
new SqlParameter("@StcrntAdd", ObjStudent.StudentCrntAdd),
new SqlParameter("@StcrntState", ObjStudent.StudentCrntState),
new SqlParameter("@StcrntCity", ObjStudent.StudentCrntCity),
new SqlParameter("@StcrntLoc", ObjStudent.StudentCrntLocation),
new SqlParameter("@StcrntPin", ObjStudent.StudentCrntPin)
};
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "StudentDetail_Insert_Sp", paramList);
}
|
|
|
|
|
Share the Databind code for drpCrntState .
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
public void BindCStateDrp()
{
var stateList = balStateObj.GetState(0);
drpCrntState.DataSource = stateList;
drpCrntState.DataTextField = "StateName";
drpCrntState.DataValueField = "StateID";
drpCrntState.DataBind();
drpCrntState.Items.Insert(0, new ListItem("--Select State--", "-1"));
}
DAL
-----------------
public List<BOState> GetStates(int stateID)
{
List<BOState> lstState = new List<BOState>();
try
{
SqlParameter[] paramList =
{
new SqlParameter("@State_Id" , stateID)
};
SqlDataReader reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "State_Select_Sp", paramList);
while (reader.Read())
{
BOState state = new BOState();
state.StateID = (Int32)reader[0];
state.StateName = (String)reader[1];
state.StateStatus = (bool)reader[2];
lstState.Add(state);
}
}
catch
{
}
return lstState;
}
|
|
|
|
|
Based on your question & this discussion[^], you have used SelectedValue property instead of DataValueField .
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
This error occurred when your dropdown is already filled and if you try to assign (selects) that value which was selected previously. so can you provide your code?
|
|
|
|
|
thank you ajay sir i have solve my porblem...with your suport...
tripat bala singh
|
|
|
|
|
welcome dear!!!
keep it up...
|
|
|
|
|
Hi Friend,
put you code inside on IsPostBack ==false like below code and put the DataTextField and DataValueField properly like this. this code should be in Page_Load events.
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("your connection string here");
SqlDataAdapter da = new SqlDataAdapter("Select StateId,StateName From StateMaster", con);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "StateName"; // your dispaly field in dropdownlist
DropDownList1.DataValueField = "StateId"; // your value field which you will stare in database
DropDownList1.DataBind();
con.Close();
}
Anil Pathak
worked on technologies like C#, VB.net, ASP.net, Web Service, WCF, WPF, Silver Light, MVC 3.0, Jquery, Sql Server.
|
|
|
|
|
thank you anil sir i have solve my porblem...with your suport...
tripat bala singh
|
|
|
|
|
I just saw IE11 preview is available.
I am so seriously sick of this , every-time Microsoft pushes out a new browser we get a crap load of support call over websites not working or displaying incorrectly.
Yes Firefox has a much more frequent release schedule but at least they keep things the same.
Every single IE version is like a whole new compulsory browser we have to babysit , because we have to consider everyone who hasn't upgraded to the latest version
The Last time Microsoft released a browser version the entire Authentication based system for their own framework went to hell , and we had a whole bunch of very p-d of customers phoning us. Never mind the huge amount of dev resources we had to pull off projects to fix existing projects.
My question is when Microsoft make screw ups like this , at what point can we start sending our development bill to them ?!
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
This is not the place for this sort of rant. Either use the Lounge[^], or one of Microsoft's own websites.
Veni, vidi, abiit domum
|
|
|
|
|
how to split an excel workbook into two when it exceeds 600 kb in c#.net
|
|
|
|
|
|
hello frnds , iam new to the CMS. show me the sample example
Mr.VJ
|
|
|
|
|
Not a specific question but this[^] could have help you.
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
1 - i make text box with auto complicate extended
2- i pot my connection string
"
<connectionStrings>
<add name="conn" connectionString="Data Source=.;Initial Catalog=Tranning;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="tempdbConn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\tempdb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
"
and i make method
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> SearchCustomers(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["conn"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select No_Trainee from Annual_Plan where No_Trainee like @SearchText + '%' ";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> customers = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(sdr["No_Trainee"].ToString());
}
}
conn.Close();
return customers;
}
}
}
and still my text Box not get values from database
Please need help !!!
|
|
|
|
|