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

ASP.NET

 
AnswerRe: Application designing issue Pin
carlecomm26-Nov-09 14:45
carlecomm26-Nov-09 14:45 
QuestionDetailsView Update Problem Pin
RajpootRohan24-Nov-09 18:11
professionalRajpootRohan24-Nov-09 18:11 
AnswerRe: DetailsView Update Problem Pin
Nishant Singh24-Nov-09 20:07
Nishant Singh24-Nov-09 20:07 
GeneralRe: DetailsView Update Problem Pin
RajpootRohan24-Nov-09 20:29
professionalRajpootRohan24-Nov-09 20:29 
GeneralRe: DetailsView Update Problem Pin
Nishant Singh24-Nov-09 21:20
Nishant Singh24-Nov-09 21:20 
GeneralRe: DetailsView Update Problem Pin
RajpootRohan24-Nov-09 23:10
professionalRajpootRohan24-Nov-09 23:10 
GeneralRe: DetailsView Update Problem Pin
sashidhar24-Nov-09 21:30
sashidhar24-Nov-09 21:30 
QuestionReal problem with GridView TemplateField Sorting Pin
Maxdd 724-Nov-09 6:30
Maxdd 724-Nov-09 6:30 
I have a big GridView (with, edit,update,delete and insert operations),(forgive all this code, I cant present my problem other way Cry | :((

The template field is like this: (the gridview has OnPageIndexChanging="GridView3_PageIndexChanging" OnSorting="GridView3_Sorting" AllowSorting="True" properties)

<asp:TemplateField HeaderText="Nome" SortExpression="Nome">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtname" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblname" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>
                        <asp:TextBox ID="txtNName" runat="server" width="75px" Visible='<%# (bool) show_hide_insert() %>'> </asp:TextBox>
                    </FooterTemplate>
                            </asp:TemplateField>


The Grid View is populated this way:

public void TempTable()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("ID", typeof(int));
        dt.Columns.Add("Name", typeof(String));
        dt.Columns.Add("Year", typeof(String));

// i've erased some colummns here

        dt.Columns.Add("Image", typeof(String));



        Session["data"] = dt;
        Temp = dt.Copy();
      
// query. ...

        DataSet ds = GetData(query);
        GridView3.DataSource = ds;
        GridView3.DataBind();

    }

DataSet GetData(String queryString)
    {

        string connectionString;
        connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
        DataSet ds = new DataSet();

        try
        {
         
            SqlConnection Conn = new SqlConnection(connectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(queryString, connectionString);
            adapter.Fill(ds);

        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);

        }

        return ds;
    }

public DataTable Temp
    {
        get
        {
            object o = ViewState["Temp"];
            if (o == null)
            {
                DataTable dt = new DataTable();
                return dt;
            }
            else
                return (DataTable)o;
        }
        set
        {
            ViewState["Temp"] = value;
        }
    }


And then I'm trying to sort this way:

private string ConvertSortDirectionToSql(SortDirection sortDirection)
    {
        string newSortDirection = String.Empty;

        switch (sortDirection)
        {
            case SortDirection.Ascending:
                newSortDirection = "ASC";
                break;

            case SortDirection.Descending:
                newSortDirection = "DESC";
                break;
        }

        return newSortDirection;
    }

    protected void GridView3_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        
        GridView3.PageIndex = e.NewPageIndex;
        GridView3.DataBind();
    }

    protected void GridView3_Sorting(object sender, GridViewSortEventArgs e)
    {
        DataTable dataTable = GridView3.DataSource as DataTable;

        if (dataTable != null)
        {
            DataView dataView = new DataView(dataTable);
            dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);

            GridView3.DataSource = dataView;
            GridView3.DataBind();
        }
    }


I think its because I'm using the temporary table, but dont know how to aply that here on sorting... Can you help me please?
AnswerRe: Real problem with GridView TemplateField Sorting Pin
Maxdd 724-Nov-09 7:31
Maxdd 724-Nov-09 7:31 
GeneralRe: Real problem with GridView TemplateField Sorting Pin
Christian Graus24-Nov-09 7:32
protectorChristian Graus24-Nov-09 7:32 
GeneralRe: Real problem with GridView TemplateField Sorting [modified] Pin
Maxdd 724-Nov-09 10:33
Maxdd 724-Nov-09 10:33 
GeneralRe: Real problem with GridView TemplateField Sorting Pin
Christian Graus24-Nov-09 11:18
protectorChristian Graus24-Nov-09 11:18 
GeneralRe: Real problem with GridView TemplateField Sorting Pin
Maxdd 724-Nov-09 11:53
Maxdd 724-Nov-09 11:53 
GeneralRe: Real problem with GridView TemplateField Sorting Pin
Christian Graus24-Nov-09 12:02
protectorChristian Graus24-Nov-09 12:02 
GeneralRe: Real problem with GridView TemplateField Sorting Pin
Maxdd 724-Nov-09 15:25
Maxdd 724-Nov-09 15:25 
AnswerRe: Real problem with GridView TemplateField Sorting Pin
Abhishek Sur24-Nov-09 9:00
professionalAbhishek Sur24-Nov-09 9:00 
QuestionHow can we find the application which caused the failure of email. Pin
chandra vempati24-Nov-09 6:28
chandra vempati24-Nov-09 6:28 
AnswerRe: How can we find the application which caused the failure of email. Pin
Christian Graus24-Nov-09 6:45
protectorChristian Graus24-Nov-09 6:45 
AnswerRe: How can we find the application which caused the failure of email. Pin
Abhishek Sur24-Nov-09 9:06
professionalAbhishek Sur24-Nov-09 9:06 
Questionasp to asp.net migration Pin
FEMDEV24-Nov-09 4:15
FEMDEV24-Nov-09 4:15 
AnswerRe: asp to asp.net migration Pin
The Man from U.N.C.L.E.24-Nov-09 4:33
The Man from U.N.C.L.E.24-Nov-09 4:33 
AnswerRe: asp to asp.net migration Pin
Abhishek Sur24-Nov-09 4:36
professionalAbhishek Sur24-Nov-09 4:36 
GeneralRe: asp to asp.net migration Pin
FEMDEV24-Nov-09 4:48
FEMDEV24-Nov-09 4:48 
QuestionCookies Pin
manish.m.meshram24-Nov-09 0:35
manish.m.meshram24-Nov-09 0:35 
AnswerRe: Cookies Pin
Abhijit Jana24-Nov-09 0:43
professionalAbhijit Jana24-Nov-09 0:43 

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.