protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ShowAllProjects();
}
}
------------------------------------
public void ShowAllProjects()
{
DataTable dt = new DataTable();
dt = NSBuilder.DataAccess.GetDataSet("Usp_BindCategory_ForSortingTest").Tables[0];
if (dt.Rows.Count > 0)
{
gridAllProjects.Visible = true;
gridAllProjects.DataSource = dt;
gridAllProjects.DataBind();
}
else
{
gridAllProjects.Dispose();
gridAllProjects.Visible = false;
}
}
---------------------------------
protected void gridAllProjects_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
TableCell tc = new TableCell();
TableCell tc1 = new TableCell();
tc.Text = "[Page:";
tc1.Text = "]";
Table tbl = new Table();
tbl = (Table)(e.Row.Cells[0].Controls[0]);
tbl.Rows[0].Cells.AddAt(gridAllProjects.PageIndex, tc);
tbl.Rows[0].Cells.AddAt(gridAllProjects.PageIndex + 2, tc1);
}
}
---------------------------------------
protected void gridAllProjects_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
TableCell cell = e.Row.Cells[0];
cell.ColumnSpan = 2;
for (int i = 65; i <= (65 + 25); i++)
{
LinkButton lb = new LinkButton();
lb.Text = Char.ConvertFromUtf32(i) + " ";
lb.CommandArgument = Char.ConvertFromUtf32(i);
lb.CommandName = "AlphaPaging";
cell.Controls.Add(lb);
lb.ToolTip = "Click to find the categories starting with :- " + lb.Text;
// lb.BackColor = System.Drawing.ColorTranslator.FromHtml("#6b8ade");
lb.CssClass = "simple";
// lb.Attributes.Add("onmouseover","style='backbol
// lb.Style.Add("background-color", "red");
if (! CheckCategoryExistsOrNot(lb.Text))
{
lb.Visible = false;
}
}
}
}
-------------------------------------
public bool CheckCategoryExistsOrNot(string s)
{
DataTable dt = new DataTable();
Hashtable ht = new Hashtable();
ht.Add("@C", s);
string result;
bool r;
result = Convert.ToString(NSBuilder.DataAccess.ExecuteNonQueryWithReturnParameter
("Usp_CheckCategorEXITSOrNOTForSortingTest",ht));
if (result == "1")
{
r = true;
}
else
{
r= false;
}
return r;
}
-------------------------------------
protected void gridAllProjects_RowCommand(object sender, GridViewCommandEventArgs e)
{
DataTable dt = new DataTable();
Hashtable ht = new Hashtable();
if (e.CommandName.Equals("AlphaPaging"))
{
ht.Add("@C", e.CommandArgument.ToString());
dt = NSBuilder.DataAccess.GetDataSet("Usp_BindCategory_ForSortingTest", ht).Tables[0];
gridAllProjects.DataSource = dt;
gridAllProjects.DataBind();
}
}
----------------------------------------
protected void gridAllProjects_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridAllProjects.PageIndex = e.NewPageIndex;
ShowAllProjects();
}
}
---------------stored proc-----------------
alter PROCEDURE [dbo].[Usp_CheckCategorEXITSOrNOTForSortingTest]
(
@C Char(1) = null
) -- Usp_CheckCategorEXITSOrNOTForSortingTest 'A'
AS
BEGIN
DECLARE @VAR INT
IF EXISTS (SELECT CATEGORY FROM tbl_Category WHERE Category LIKE @C + '%')
SET @VAR = 1
ELSE
SET @VAR = -1
END
--PRINT @VAR
RETURN @VAR
------css class----
.simple
{
background-color:#bd0000;
color:#ffffff;
}
.simple:hover
{
background-color:#ffffff;
color:#bd0000;
}
--------------------
{
if (!Page.IsPostBack)
{
ShowAllProjects();
}
}
------------------------------------
public void ShowAllProjects()
{
DataTable dt = new DataTable();
dt = NSBuilder.DataAccess.GetDataSet("Usp_BindCategory_ForSortingTest").Tables[0];
if (dt.Rows.Count > 0)
{
gridAllProjects.Visible = true;
gridAllProjects.DataSource = dt;
gridAllProjects.DataBind();
}
else
{
gridAllProjects.Dispose();
gridAllProjects.Visible = false;
}
}
---------------------------------
protected void gridAllProjects_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
TableCell tc = new TableCell();
TableCell tc1 = new TableCell();
tc.Text = "[Page:";
tc1.Text = "]";
Table tbl = new Table();
tbl = (Table)(e.Row.Cells[0].Controls[0]);
tbl.Rows[0].Cells.AddAt(gridAllProjects.PageIndex, tc);
tbl.Rows[0].Cells.AddAt(gridAllProjects.PageIndex + 2, tc1);
}
}
---------------------------------------
protected void gridAllProjects_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
TableCell cell = e.Row.Cells[0];
cell.ColumnSpan = 2;
for (int i = 65; i <= (65 + 25); i++)
{
LinkButton lb = new LinkButton();
lb.Text = Char.ConvertFromUtf32(i) + " ";
lb.CommandArgument = Char.ConvertFromUtf32(i);
lb.CommandName = "AlphaPaging";
cell.Controls.Add(lb);
lb.ToolTip = "Click to find the categories starting with :- " + lb.Text;
// lb.BackColor = System.Drawing.ColorTranslator.FromHtml("#6b8ade");
lb.CssClass = "simple";
// lb.Attributes.Add("onmouseover","style='backbol
// lb.Style.Add("background-color", "red");
if (! CheckCategoryExistsOrNot(lb.Text))
{
lb.Visible = false;
}
}
}
}
-------------------------------------
public bool CheckCategoryExistsOrNot(string s)
{
DataTable dt = new DataTable();
Hashtable ht = new Hashtable();
ht.Add("@C", s);
string result;
bool r;
result = Convert.ToString(NSBuilder.DataAccess.ExecuteNonQueryWithReturnParameter
("Usp_CheckCategorEXITSOrNOTForSortingTest",ht));
if (result == "1")
{
r = true;
}
else
{
r= false;
}
return r;
}
-------------------------------------
protected void gridAllProjects_RowCommand(object sender, GridViewCommandEventArgs e)
{
DataTable dt = new DataTable();
Hashtable ht = new Hashtable();
if (e.CommandName.Equals("AlphaPaging"))
{
ht.Add("@C", e.CommandArgument.ToString());
dt = NSBuilder.DataAccess.GetDataSet("Usp_BindCategory_ForSortingTest", ht).Tables[0];
gridAllProjects.DataSource = dt;
gridAllProjects.DataBind();
}
}
----------------------------------------
protected void gridAllProjects_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridAllProjects.PageIndex = e.NewPageIndex;
ShowAllProjects();
}
}
---------------stored proc-----------------
alter PROCEDURE [dbo].[Usp_CheckCategorEXITSOrNOTForSortingTest]
(
@C Char(1) = null
) -- Usp_CheckCategorEXITSOrNOTForSortingTest 'A'
AS
BEGIN
DECLARE @VAR INT
IF EXISTS (SELECT CATEGORY FROM tbl_Category WHERE Category LIKE @C + '%')
SET @VAR = 1
ELSE
SET @VAR = -1
END
--PRINT @VAR
RETURN @VAR
------css class----
.simple
{
background-color:#bd0000;
color:#ffffff;
}
.simple:hover
{
background-color:#ffffff;
color:#bd0000;
}
--------------------
0 comments:
Post a Comment