Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i enable sorting for this grid?? 1

Status
Not open for further replies.

jwrz200t

Programmer
Aug 1, 2006
19
US
I have a grid with the following code. How do i enable bi-directional sorting to my columns???


<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" AllowPaging="True" PageSize="15" OnPageIndexChanging="GridView1_PageIndexChanging" AllowSorting="True" >

<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />

<RowStyle BackColor="#EBEBEB" />

<EditRowStyle BackColor="#7C6F57" />

<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />

<PagerStyle BackColor="#0A4A13" ForeColor="White" HorizontalAlign="Center" />

<HeaderStyle BackColor="#0A4A13" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="White" />

<Columns>

<asp:CommandField ShowSelectButton="True" />

<asp:TemplateField HeaderText="ID">

<EditItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>

</EditItemTemplate>

<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# Bind("ID") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="UL">

<EditItemTemplate>

<asp:Label ID="Label2" runat="server" Text='<%# Eval("UL") %>'></asp:Label>

</EditItemTemplate>

<ItemTemplate>

<asp:Label ID="Label2" runat="server" Text='<%# Bind("UL") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="LAST_NAME" HeaderText="Last N" SortExpression = "LAST_NAME" />

<asp:BoundField DataField="FIRST_NAME" HeaderText="First N" SortExpression = "FIRST_NAME"/>

<asp:BoundField DataField="DATE" HeaderText="Date Registered" SortExpression = "DATE"/>



</Columns>

</asp:GridView>







protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

{

GridViewRow row = GridView1.SelectedRow;



Label lblID = row.FindControl("Label1") as Label;

Label lblUL = row.FindControl("Label2") as Label;



Session["myID"] = lblID.Text;

Session["myUl"] = lblUL.Text;



string strFullname = Session["userFname"].ToString() + " " + Session["userLname"].ToString();

DateTime today = DateTime.Now;

string strDateLastViewed = today.ToString();

sql mySqlQuery = new sql();

mySqlQuery.queryDbVoid("UPDATE USED_LOG SET LAST_VIEWED_BY = '" + strFullname + "', DATE_LAST_VIEWED = '" + strDateLastViewed + "' WHERE (" + "UL = '" + lblUL.Text + "') AND " + "(ID = '" + lblID.Text + "')", ref lblResultsError);



Response.Redirect("summary.aspx");

}//END GridView1_SelectedIndexChanged





protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

GridView1.PageIndex = e.NewPageIndex;

dataBind(Session["myQuery"].ToString());

}



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top