Click here to Skip to main content
15,895,084 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Session Pin
_AK_13-Jun-07 20:17
_AK_13-Jun-07 20:17 
AnswerRe: Session Pin
Chetan Ranpariya12-Jun-07 20:48
Chetan Ranpariya12-Jun-07 20:48 
AnswerRe: Session Pin
Sathesh Sakthivel12-Jun-07 20:49
Sathesh Sakthivel12-Jun-07 20:49 
Questionasp.net Pin
ling_luv12-Jun-07 20:21
ling_luv12-Jun-07 20:21 
AnswerRe: asp.net Pin
Chetan Ranpariya12-Jun-07 20:23
Chetan Ranpariya12-Jun-07 20:23 
GeneralRe: asp.net Pin
ling_luv12-Jun-07 20:26
ling_luv12-Jun-07 20:26 
AnswerRe: asp.net Pin
Chetan Ranpariya12-Jun-07 20:45
Chetan Ranpariya12-Jun-07 20:45 
QuestionSorting problem in GridView [modified] Pin
Amr M. K.12-Jun-07 20:16
Amr M. K.12-Jun-07 20:16 
I have Table News
NewsID, int
NewsHeadLint, varcahr(200)
OrderNews, int

I gridView Display as following query
Select ID,NewsHeadLine from News order By OrderNews DESC
----
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="NewsID" EmptyDataText="There are no data records to display."
DataSourceID="SqlDataSource1" Style="position: relative; left: 4px; top: 44px;" OnRowCommand="Grid1_Command" AllowPaging="True" PageSize="8" Width="571px" >
I have Add in gridView 2 buttonField
<asp:ButtonField ButtonType="Image" CommandName="CmdUp"..
<asp:ButtonField ButtonType="Image" CommandName="CmdDown"
..

CmdUP(command up) get the value of current order row and row the above in gridView and
swtich between them
In CS code
protected void Grid1_Command(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{

// Object o = sender;


String z = (String)e.CommandArgument;

int indexGrid = Convert.ToInt16(z);
String CommandNamew = e.CommandName.ToString();
switch (CommandNamew)
{
//-------------------------------------------


case "CmdUp":
{

//I have write query and correctly excute in Database




String NewsIDcurrent = GridView1.DataKeys[indexGrid].Value.ToString().Trim(); //IDnews
//Response.Write(GridView1.DataKeys[Convert.ToInt16 (z)].Values[0].ToString());

SqlCommand Cmd = new SqlCommand();
Cmd.Connection = conn;




if ((indexGrid + 1) != GridView1.DataKeys.Count)
{

//NewsIDvalue this the current Id
String NewsIDunder = GridView1.DataKeys[indexGrid + 1].Value.ToString().Trim();
try
{
conn.Open();
//---Current
Cmd.CommandText = "Select OrderNews from News where NewsID=" + NewsIDcurrent;
int orderVal = (int)Cmd.ExecuteScalar();


Cmd.Parameters.Clear();



Cmd.CommandText = "Select OrderNews from News where NewsID=" + NewsIDunder;

int orderUnder = (int)Cmd.ExecuteScalar();
Cmd.Parameters.Clear();

Cmd.CommandText = "update News Set OrderNews=" + Convert.ToString(orderUnder) + " where NewsID=" + NewsIDcurrent;
Cmd.ExecuteNonQuery();

//--Under
Cmd.Parameters.Clear();


Cmd.CommandText = "update News Set OrderNews=" + Convert.ToString(orderVal) + " where NewsID=" + NewsIDunder;
Cmd.ExecuteNonQuery();



Cmd.Parameters.Clear();


// GridView1.DataBind();
}

catch (Exception ex)
{

}

finally
{
conn.Close();
// Response.Redirect("NewsCollection.aspx"); with it or without it
}






}

break;
}//end cmddown


case "CmdDown":
{


//I have write query and correctly excute in Database same idea as above

break;


}
default: { break; }

............




I have problem with this command( excute twice,or not display the result unless u refresh the browser..)what excatly best way to write and what event I must to write in the webpage(_Load _preRender..)


aj123


-- modified at 2:26 Wednesday 13th June, 2007
QuestionHTTP STATELESS.. Pin
Rahul8312-Jun-07 19:55
Rahul8312-Jun-07 19:55 
AnswerRe: HTTP STATELESS.. Pin
Elizma12-Jun-07 20:02
Elizma12-Jun-07 20:02 
GeneralRe: HTTP STATELESS.. Pin
Rahul8312-Jun-07 20:16
Rahul8312-Jun-07 20:16 
GeneralRe: HTTP STATELESS.. Pin
ShuklaGirish12-Jun-07 20:55
ShuklaGirish12-Jun-07 20:55 
AnswerRe: HTTP STATELESS.. Pin
SimulationofSai12-Jun-07 22:49
SimulationofSai12-Jun-07 22:49 
GeneralRe: HTTP STATELESS.. Pin
Rahul8312-Jun-07 23:05
Rahul8312-Jun-07 23:05 
GeneralRe: HTTP STATELESS.. Pin
SimulationofSai13-Jun-07 1:30
SimulationofSai13-Jun-07 1:30 
QuestionASP.Net Tree View--urgent Pin
venkata lakshmi prasanna12-Jun-07 19:45
venkata lakshmi prasanna12-Jun-07 19:45 
AnswerRe: ASP.Net Tree View--urgent Pin
Sathesh Sakthivel12-Jun-07 19:51
Sathesh Sakthivel12-Jun-07 19:51 
GeneralRe: ASP.Net Tree View--urgent Pin
venkata lakshmi prasanna12-Jun-07 20:36
venkata lakshmi prasanna12-Jun-07 20:36 
GeneralRe: ASP.Net Tree View--urgent Pin
Bajrang Singh13-Jun-07 4:22
Bajrang Singh13-Jun-07 4:22 
AnswerRe: ASP.Net Tree View--urgent Pin
leckey13-Jun-07 4:37
leckey13-Jun-07 4:37 
Questionopening other website inside my website Pin
alok.mailbox12-Jun-07 19:40
alok.mailbox12-Jun-07 19:40 
AnswerRe: opening other website inside my website Pin
Chetan Ranpariya12-Jun-07 19:46
Chetan Ranpariya12-Jun-07 19:46 
AnswerRe: opening other website inside my website Pin
Prakash_Mishra12-Jun-07 19:48
Prakash_Mishra12-Jun-07 19:48 
GeneralRe: opening other website inside my website Pin
alok.mailbox13-Jun-07 2:05
alok.mailbox13-Jun-07 2:05 
AnswerRe: opening other website inside my website Pin
Sathesh Sakthivel12-Jun-07 19:53
Sathesh Sakthivel12-Jun-07 19:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.