|
|
Hi
Can any one give me code for gridview sorting. I am using dataset as datasource of gridview.
Thanks & Regards
Mishra
|
|
|
|
|
|
private DataSet GetData()<br />
{<br />
SqlConnection myConnection = new SqlConnection(ConnectionString);<br />
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection);<br />
<br />
DataSet ds = new DataSet();<br />
ad.Fill(ds);<br />
return ds; <br />
}<br />
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" OnSorting="GridView1_Sorting"><br />
</asp:GridView><br />
<br />
public SortDirection GridViewSortDirection<br />
{<br />
get<br />
{<br />
if (ViewState["sortDirection"] == null)<br />
ViewState["sortDirection"] = SortDirection.Ascending;<br />
return (SortDirection) ViewState["sortDirection"]; <br />
}<br />
<br />
set { ViewState["sortDirection"] = value; } <br />
}<br />
<br />
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)<br />
{<br />
string sortExpression = e.SortExpression;<br />
if (GridViewSortDirection == SortDirection.Ascending)<br />
{<br />
GridViewSortDirection = SortDirection.Descending;<br />
SortGridView(sortExpression, DESCENDING);<br />
}<br />
else<br />
{<br />
GridViewSortDirection = SortDirection.Ascending;<br />
SortGridView(sortExpression, ASCENDING); <br />
} <br />
}<br />
<br />
private void SortGridView(string sortExpression,string direction)<br />
{<br />
DataTable dt = GetData().Tables[0]; <br />
DataView dv = new DataView(dt); <br />
dv.Sort = sortExpression + direction; <br />
GridView1.DataSource = dv;<br />
GridView1.DataBind(); <br />
}<br />
Ramana
|
|
|
|
|
Go to Properties of Grid View and Set Allow Sorting as TRUE
|
|
|
|
|
How to Upload Image in asp.net 2.0?
|
|
|
|
|
Use File control of asp.net
mbmb
|
|
|
|
|
I want to Upload Image from hard drive and save in Image folder in my project.... I am using File Upload control....Send me code for button click event
|
|
|
|
|
<br />
protected void UploadBtn_Click(object sender, EventArgs e)<br />
{<br />
if (FileUpLoad1.HasFile)<br />
{<br />
FileUpLoad1.SaveAs(@"C:\temp\" + FileUpLoad1.FileName);<br />
Label1.Text = "File Uploaded: " + FileUpLoad1.FileName ;<br />
}<br />
else<br />
Label1.Text = "No File Uploaded.";<br />
}<br />
Ramana
|
|
|
|
|
I want to Save Uploaded Image in my project... But when i use ur code the image was not in the target location(C:\temp)...
|
|
|
|
|
use Server.MapPath(""); instead of c:\temp
if u are storing in sepearate folder, u have to set folder write Permissions, right click goto security tab...
Ramana
|
|
|
|
|
please help me. how can i display my content using pagination.
|
|
|
|
|
Two applications are accessing a same database.First is the vb6 application and another is the asp.net c# website.Now my question is when the website access the database , after completing the request it closes the question , still it renders the database in read only file state.y this is happening?
Soniagupta1@yahoo.co.in
|
|
|
|
|
use transactions in asp.net applications & apply locks to that DB.
Ramana
|
|
|
|
|
how to check different browser in javascript
Piyush Vardhan Singh
Senior Software Engineer
TAS NewDelhi
India
|
|
|
|
|
navigator.appName returns the name of browser.
navigator.appVersion returns the verson of browser.
Check it BrowserJS
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
hi all,
Iam trying to create a new user programmatically by using Membership.CreateUser(username As String, password As String). When I try to create a new user by using the code below, I get following errormessage
Error 102 Validation (ASP.Net): Attribute values must be enclosed in quotation marks.
MembershipCreateUserException: The password-answer supplied is invalid
and I do not understand what I am doing wrong. I hope someone can help me with this.
Kareem Elhosseny
|
|
|
|
|
Membership.CreateUser(string, string) will returns a MembershipUser object for newly created user.
Retrieve a MembershipCreateStatus value from the StatusCode property of the MembershipCreateUserException that indicates why user creation failed.
MembershipCreateStatus object will returns the follwing status codes
DuplicateEmail: The e-mail address already exists in the database for the application. <br />
DuplicateProviderUserKey: The provider user key already exists in the database for the application. <br />
DuplicateUserName: The user name already exists in the database for the application. <br />
InvalidAnswer: The password answer is not formatted correctly. <br />
InvalidEmail: The e-mail address is not formatted correctly. <br />
InvalidPassword: The password is not formatted correctly. <br />
InvalidProviderUserKey: The provider user key is of an invalid type or format. <br />
InvalidQuestion: The password question is not formatted correctly. <br />
InvalidUserName: The user name was not found in the database. <br />
ProviderError: The provider returned an error that is not described by other MembershipCreateStatus: enumeration values. <br />
Success: The user was successfully created. <br />
UserRejected: The user was not created, for a reason defined by the provider
capture the status & based on this status use overloaded CreateUser function
Ramana
|
|
|
|
|
i'll try it
thx romana for your attention
Kareem Elhosseny
|
|
|
|
|
here is my exactelly code but it dosnt work the error related to the password format but i dont know it specificelly
MembershipUser newuser= Membership.CreateUser("kareem", "P@ssw0rd");
plz answer me Romana
Kareem Elhosseny
|
|
|
|
|
see this code
<br />
public void CreateUser_OnClick(object sender, EventArgs args)<br />
{<br />
<br />
MembershipCreateStatus status;<br />
string passwordQuestion = "";<br />
string passwordAnswer = "";<br />
<br />
if (Membership.RequiresQuestionAndAnswer)<br />
{<br />
passwordQuestion = PasswordQuestionTextbox.Text;<br />
passwordAnswer = PasswordAnswerTextbox.Text;<br />
}<br />
<br />
try<br />
{<br />
MembershipUser newUser = Membership.CreateUser(UsernameTextbox.Text, PasswordTextbox.Text,EmailTextbox.Text, passwordQuestion, passwordAnswer, true, out status);<br />
if (newUser == null)<br />
{<br />
Msg.Text = GetErrorMessage(status);<br />
}<br />
else<br />
{<br />
Response.Redirect("login.aspx");<br />
}<br />
}<br />
catch<br />
{<br />
Msg.Text = "An exception occurred creating the user.";<br />
}<br />
}<br />
<br />
public string GetErrorMessage(MembershipCreateStatus status)<br />
{<br />
switch (status)<br />
{<br />
case MembershipCreateStatus.DuplicateUserName:<br />
return "Username already exists. Please enter a different user name.";<br />
<br />
case MembershipCreateStatus.DuplicateEmail:<br />
return "A username for that e-mail address already exists. Please enter a different e-mail address.";<br />
<br />
case MembershipCreateStatus.InvalidPassword:<br />
return "The password provided is invalid. Please enter a valid password value.";<br />
<br />
case MembershipCreateStatus.InvalidEmail:<br />
return "The e-mail address provided is invalid. Please check the value and try again.";<br />
<br />
case MembershipCreateStatus.InvalidAnswer:<br />
return "The password retrieval answer provided is invalid. Please check the value and try again.";<br />
<br />
case MembershipCreateStatus.InvalidQuestion:<br />
return "The password retrieval question provided is invalid. Please check the value and try again.";<br />
<br />
case MembershipCreateStatus.InvalidUserName:<br />
return "The user name provided is invalid. Please check the value and try again.";<br />
<br />
case MembershipCreateStatus.ProviderError:<br />
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";<br />
<br />
case MembershipCreateStatus.UserRejected:<br />
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";<br />
<br />
default:<br />
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";<br />
}<br />
}<br />
<br />
Note: if u r using overloaded CreateUser function pass the non required parameters as null and check
Ramana
|
|
|
|
|
really thx alot for your effort
but the createuser method have an overload takes two variables username and password only so i did't have to check in
if (Membership.RequiresQuestionAndAnswer)
{
passwordQuestion = PasswordQuestionTextbox.Text;
passwordAnswer = PasswordAnswerTextbox.Text;
}
and when i try your code its give me there is an exeption sothe result write in the msg label "An exception occurred creating the user"
i think my problem in the formating of password
and the exeption told me that
wht can i do ?
Kareem Elhosseny
|
|
|
|
|
Try a different password?
|
|
|
|
|
i have survey project.
i have consecutive 5 pages.
and each pages have some controls.
i want to use all the previous 4 pages values on last 5 th page
i don't want to use following techniques.
session
cache
application
context
previoupagedirectory
querystring
is there any other techniques to solve my problem
MBMB
|
|
|
|
|
create one class,
add static variables to that class,
in last page, retrive from these variables and save.....
Ramana
|
|
|
|