I use two store procedures
this store procedure for fetching data.
ALTER PROCEDURE UCUGrideview
(
@pass varchar(max)
)
AS
begin
set nocount on
exec(@pass)
set nocount off
end
this store procedure for delete record
ALTER PROCEDURE UCUGrideviewDelete
(
@TABLE varchar(50),
@COLUMNNAME varchar(50),
@SCHEMA varchar(50),
@VALUE varchar(max)
)
AS
SET NOCOUNT ON
DECLARE @sql varchar(max)
begin
set @sql=('UPDATE '+@SCHEMA+'.'+@TABLE+' SET Is_Active=0 where '+@COLUMNNAME+' in('+@VALUE+')')
exec(@sql)
SET NOCOUNT OFF
end
DAL code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace .DataAccessLayer
{
public partial class UERPDataAccess
{
DataTable dt = new DataTable();
public void delete(UCUGrideview obj,string value)
{
SqlCommand cm = new SqlCommand("UCUGrideviewDelete");
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.AddWithValue("@TABLE", obj.TABLENAME);
cm.Parameters.AddWithValue("@COLUMNNAME", obj.COLNAME[0].ToString());
cm.Parameters.AddWithValue("@SCHEMA", obj.SCHEMA);
cm.Parameters.AddWithValue("@VALUE", value);
ExecuteStoredProcedure(cm);
}
public DataTable UCUGrideviewdata(UCUGrideview obj)
{
int i;
string s = string.Empty;
string ss = string.Empty;
SqlCommand cm = new SqlCommand("UCUGrideview");
cm.CommandType = CommandType.StoredProcedure;
string[] t = obj.COLNAME[0].ToString().Split('=');
if (t[0].Trim() == "*")
{
ss = "select * from " + obj.SCHEMA.ToString() + "." + obj.TABLENAME.ToString() + " where Is_Active=1";
}
else
{
if (t.GetLength(0) > 1)
{
for (i = 0; i < obj.COLNAME.Count; i++)
{
string[] tt = obj.COLNAME[i].ToString().Split('=');
s = s + tt[0].ToString() + " " + tt[1].ToString() + ",";
}
ss = "select " + s.Substring(0, s.LastIndexOf(',')) + " from " + obj.SCHEMA.ToString() + "." + obj.TABLENAME.ToString() + " where Is_Active=1";
}
else
{
for (i = 0; i < obj.COLNAME.Count; i++)
s = s + obj.COLNAME[i].ToString() + ",";
ss = "select " + s.Substring(0, s.LastIndexOf(',')) + " from " + obj.SCHEMA.ToString() + "." + obj.TABLENAME.ToString() + " where Is_Active=1";
}
}
cm.Parameters.AddWithValue("@pass", ss);
dt.Clear();
dt.Reset();
dt = ExecuteGetDataTable(cm);
return dt;
}
}
}
user control design code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCUGrideview.ascx.cs" Inherits="Website.App_WebControls.UAMS_UserControls.UCUGrideview" %>
<script language="javascript" type="text/javascript">
function SelectAllCheckboxes1(chk) {
var i = 0;
$('#<%=gv.ClientID%>').find("input:checkbox").each(function () {
if (this != chk) {
i = i + 1;
if (chk.checked)
this.checked = true;
else {
this.checked = false;
i = 0;
}
}
});
document.getElementById('<%=sp.ClientID%>').innerHTML = "(" + i + " selected" + ")";
}
function SelectAllCheckboxes2()
{
$.each($('#<%=gv.ClientID%>').find("tr"), function ()
{
var chk = $(this).find("th:first").find(":checkbox");
chk.attr("checked",false)
});
var m = $('#<%=gv.ClientID%>').find("tr").length
var n = 0;
$('#<%=gv.ClientID%>').find("input:checkbox").each(function () {
if (this.checked) {
n = n + 1;
}
});
document.getElementById('<%=sp.ClientID%>').innerHTML = "(" + n + " selected" + ")";
if ((parseInt(m) - 1) == parseInt(n))
$('#<%=gv.ClientID%>').find("th:first").find(":checkbox").attr("checked", true)
}
function x() {
document.getElementById('<%=tbx.ClientID %>').value = "";
}
function y() {
if( document.getElementById('<%=tbx.ClientID %>').value =="")
document.getElementById('<%=tbx.ClientID %>').value='Search for records'
}
function del()
{
var i = 0;
$('#<%=gv.ClientID%>').find("input:checkbox").each(function () {
if (this.checked)
{
i = 1;
}
});
if (i == 0) {
alert('Please select atleast one item.')
return false
}
else {
var j = confirm('Do you want to delete it.?');
if (j == true)
return true;
else
return false;
}
}
function z() {
if (document.getElementById('<%=tbx.ClientID %>').value == 'Search for records') {
alert('Please enter a search item.')
return false;
}
}
function xx() {
var m = "~`!@#$%^&*()-_+={}[]\|:;\'\"<>,.?/"
var n = document.getElementById('<%=tbx.ClientID %>')
for (var i = 0; i < n.value.length; i++)
if (m.search(n.value.charAt(i)) != -1)
alert('You can not enter special charecter.');
}
</script>
<div style="height:365px;width:99.8%;overflow:auto;border:1px solid #C1CDCD">
<table width="100%">
<tr><td colspan="2"><table width="100%"><tr><td align="left" style="width:30%">
<asp:Label ID="lbheader" runat="server" ForeColor="#666666"></asp:Label></td><td align="center" style="width:40%"><asp:TextBox ID="tbx" Width="200"
runat="server" ForeColor="#666666" onfocus="x()" onkeyup="xx()" onblur="y()">Search for records</asp:TextBox> <asp:ImageButton
ID="imbs" runat="server" ImageUrl="~/images/SearchButton.gif"
onclick="imbs_Click" OnClientClick="return z()" /></td><td align="right" style="width:30%">
<asp:ImageButton ID="im" onclientclick="return del()" runat="server"
ImageUrl="~/Uimages/delete_list.png" onclick="im_Click1" /></td></tr></table></td></tr>
<tr><td colspan="2" align="center"><asp:Label ID="message1" runat="server"
Visible="False" ForeColor="#666666"></asp:Label>
<asp:GridView ID="gv" runat="server" Width="100%" AllowSorting="True"
onsorting="gv_Sorting" onrowcreated="gv_RowCreated">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="hcb" onclick="SelectAllCheckboxes1(this)" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="cb" onclick="SelectAllCheckboxes2()" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="lbtn1" runat="server" onclick="lbtn1_Click" ></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lbtn" runat="server" onclick="lbtn_Click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Underline="true" />
</asp:GridView>
</td></tr>
<tr><td><asp:Label ID="lb2" runat="server" ForeColor="#666666"></asp:Label> <span runat="server"
id="sp" style="color: #666666">(0 selected)</span></td><td align="right">
<asp:ImageButton ID="imb" ImageUrl="~/image/PaginFirst.gif" runat="server"
onclick="imb_Click" ToolTip="First" /> <asp:ImageButton ID="imb2" ImageUrl="~/image/PaginPre.gif" runat="server"
onclick="imb2_Click" ToolTip="Previous" />
<asp:Label id="lb" runat="server" ForeColor="#666666"></asp:Label>
<asp:ImageButton ID="imb1"
ImageUrl="~/image/PaginNext.gif" ToolTip="Next" runat="server" onclick="imb1_Click" /> <asp:ImageButton ID="imb3"
ImageUrl="~/image/PaginLast.gif" ToolTip="Last" runat="server" onclick="imb3_Click" /></td></tr>
<tr><td colspan="2">
<table width="100%" style=" color:#808080"><tr>
<td><asp:LinkButton ID="lbt" runat="server" Text="All" ToolTip="View all records" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton1" runat="server" Text="#" ToolTip="View records that start with number from 0 to 9" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton2" runat="server" Text="A" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton3" runat="server" Text="B" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton4" runat="server" Text="C" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton5" runat="server" Text="D" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton6" runat="server" Text="E" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton7" runat="server" Text="F" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton8" runat="server" Text="G" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton9" runat="server" Text="H" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton10" runat="server" Text="I" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton11" runat="server" Text="J" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton12" runat="server" Text="K" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton13" runat="server" Text="L" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton14" runat="server" Text="M" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton15" runat="server" Text="N" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton16" runat="server" Text="O" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton17" runat="server" Text="P" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton18" runat="server" Text="Q" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton19" runat="server" Text="R" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton20" runat="server" Text="S" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton21" runat="server" Text="T" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton22" runat="server" Text="U" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton23" runat="server" Text="V" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton24" runat="server" Text="W" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton25" runat="server" Text="X" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton26" runat="server" Text="Y" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton27" runat="server" Text="Z" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
</tr></table>
</td></tr>
</table>
</div>
user control c# code
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swash.Objects;
using Swash.BusinessLayer;
using System.Data;
namespace Website.App_WebControls.UAMS_UserControls
{
public partial class UCUGrideview : System.Web.UI.UserControl
{
#region
int i, j, k, l, m, sk = 0,tk=0,p;
string s = string.Empty;
Swash.Objects.UCUGrideview obj1 = new Swash.Objects.UCUGrideview();
#endregion
public delegate void open(string s);
public event open popup;
protected void Page_Load(object sender, EventArgs e)
{
}
public void view(Swash.Objects.UCUGrideview obj)
{
ViewState["s"] = 0;
ViewState["ps"] = 10;
ViewState["m"] = 1;
ViewState["st"] = 1;
ViewState["pz"] = 1;
DataTable ds = new DataTable();
ds.Clear();
ds.Reset();
ds = UERPManagement.GetInstance.UCUGrideviewbusiness(obj);
ViewState["pk"] = obj.GRIDEHEADER.ToString();
ViewState["tbn"] = obj.TABLENAME.ToString();
ViewState["scm"] = obj.SCHEMA.ToString();
ViewState["clm"] = obj.COLNAME;
ViewState["ds1"] = ds;
paging(ds,1);
lbheader.Text = obj.GRIDEHEADER.ToString() + " : ";
//gv.DataKeyNames = new string[] { obj.PRIMARYKEYCOLNAME.ToString()};
}
void paging(DataTable dt, int x)
{
if (dt.Rows.Count == 0)
{
gv.DataSource = null;
gv.DataBind();
message1.Visible = true;
message1.Text = "No records available that starting with this letter. ";
lb.Visible = false;
lb2.Visible = false;
imb.Visible = false;
imb1.Visible = false;
imb2.Visible = false;
imb3.Visible = false;
sp.Visible = false;
im.Visible = false;
tbx.Text = "Search for records";
tbx.Visible = false;
imbs.Visible = false;
return;
}
else
{
lb.Visible = true;
lb2.Visible = true;
imb.Visible = true;
imb1.Visible = true;
imb2.Visible = true;
imb3.Visible = true;
sp.Visible = true;
message1.Visible = false;
im.Visible = true;
tbx.Visible = true;
imbs.Visible = true;
}
i = x;
DataTable dt2 = new DataTable();
dt2.Clear();
dt2.Reset();
ViewState["dt"] = dt;
tk = Convert.ToInt32(ViewState["ps"]);
double yy = Math.Ceiling(Convert.ToDouble(dt.Rows.Count) / Convert.ToDouble(ViewState["ps"]));
if (x == 1)
{
sk = 0;
}
else
{
if (x >= Convert.ToInt32(yy))
{
if (dt.Rows.Count % Convert.ToInt32(ViewState["ps"]) == 0)
{
x = Convert.ToInt32(yy);
sk = ((Convert.ToInt32(ViewState["ps"]) * x) - Convert.ToInt32(ViewState["ps"]));
}
else
{
x = Convert.ToInt32(yy);
sk = ((Convert.ToInt32(ViewState["ps"]) * x) - Convert.ToInt32(ViewState["ps"]));
tk = (dt.Rows.Count) - sk;
}
}
else
sk = ((Convert.ToInt32(ViewState["ps"]) * x) - Convert.ToInt32(ViewState["ps"]));
}
dt2 = ((DataTable)ViewState["dt"]).AsEnumerable().Skip(sk).Take(tk).CopyToDataTable();
if (i > Convert.ToInt32(yy))
{
i = Convert.ToInt32(yy);
ViewState["m"] = i;
}
lb.Text = "Page " + i.ToString();
string st = "";
if (tk > dt2.Rows.Count)
st = dt2.Rows.Count.ToString();
else
st = tk.ToString();
if(sk==0)
lb2.Text = 1 + "-" + st.ToString() + " of " + ((DataTable)ViewState["dt"]).Rows.Count;
else
lb2.Text =(1+sk).ToString() + "-" + st.ToString() + " of " + ((DataTable)ViewState["dt"]).Rows.Count;
gv.DataSource = dt2;
gv.DataBind();
for (int m = 0; m < dt2.Rows.Count; m++)
{
((LinkButton)gv.Rows[m].FindControl("lbtn")).CommandArgument = dt2.Rows[m][0].ToString();
((LinkButton)gv.Rows[m].FindControl("lbtn")).Text = dt2.Rows[m][1].ToString();
}
((LinkButton)gv.HeaderRow.FindControl("lbtn1")).Text = dt.Columns[1].ColumnName.ToString();
}
protected void lbt_Click(object sender, EventArgs e)
{
LinkButton lbtn=(LinkButton)sender;
DataTable ds = new DataTable();
ds.Clear();
ds.Reset();
ds = ((DataTable)ViewState["ds1"]);
DataTable dt = new DataTable();
DataView dv = new DataView();
dv = ds.DefaultView;
for (i = 0; i < ds.Columns.Count; i++)
{
dt.Columns.Add(ds.Columns[i].ColumnName, typeof(string));
}
switch (lbtn.Text)
{
case "All":
dt = ds;
break;
case "#":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
for (p = 0; p < 10; p++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= p.ToString().Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == p.ToString().Trim())
{
dv.RowFilter = "Convert(" + ds.Columns[i].ColumnName + ", 'System.String') like '" + p + "*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
}
break;
case "A":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "A".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "A")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'A*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "B":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "B".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "B")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'B*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "C":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "C".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "C")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'C*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "D":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "D".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "D")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'D*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "E":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "E".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "E")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'E*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "F":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "F".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "F")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'F*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "G":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "G".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "G")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'G*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "H":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "H".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "H")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'H*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "I":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "I".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "I")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'I*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "J":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "J".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "J")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'J*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "K":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "K".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "K")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'K*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "L":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "L".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "L")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'L*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "M":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "M".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "M")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'M*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "N":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "N".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "N")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'N*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "O":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "O".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "O")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'O*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
}
break;
}
}
}
break;
case "P":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "A".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "P")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'P*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "Q":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "Q".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "Q")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'Q*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "R":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "R".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "R")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'R*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "S":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "S".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "S")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'S*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "T":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "T".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "T")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'T*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "U":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "U".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "U")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'U*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "V":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "V".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "V")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'V*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "W":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "W".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "W")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'W*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "X":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "X".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "X")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'X*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "Y":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "Y".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "Y")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'Y*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
default:
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "Z".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "Z")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'Z*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
}
ViewState["m"] = 1;
paging(dt, 1);
}
protected void imb_Click(object sender, ImageClickEventArgs e)
{
ViewState["m"] = 1;
paging((DataTable)ViewState["dt"],Convert.ToInt32(ViewState["m"]));
}
protected void imb1_Click(object sender, ImageClickEventArgs e)
{
ViewState["m"] = Convert.ToInt32(ViewState["m"]) + 1;
paging((DataTable)ViewState["dt"], Convert.ToInt32(ViewState["m"]));
}
protected void imb2_Click(object sender, ImageClickEventArgs e)
{
ViewState["m"] = Convert.ToInt32(ViewState["m"]) - 1;
if (Convert.ToInt32(ViewState["m"]) <= 0)
ViewState["m"] = 1;
paging((DataTable)ViewState["dt"], Convert.ToInt32(ViewState["m"]));
}
protected void imb3_Click(object sender, ImageClickEventArgs e)
{
double yy = Math.Ceiling(Convert.ToDouble(((DataTable)ViewState["dt"]).Rows.Count) / Convert.ToDouble(ViewState["ps"]));
ViewState["m"] = Convert.ToInt32(yy);
paging((DataTable)ViewState["dt"], Convert.ToInt32(ViewState["m"]));
}
protected void imbs_Click(object sender, ImageClickEventArgs e)
{
DataTable ds = new DataTable();
ds.Clear();
ds.Reset();
ds = ((DataTable)ViewState["ds1"]);
DataTable dt = new DataTable();
DataView dv = new DataView();
dv = ds.DefaultView;
for (i = 0; i < ds.Columns.Count; i++)
{
dt.Columns.Add(ds.Columns[i].ColumnName, typeof(string));
}
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= tbx.Text.Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, tbx.Text.ToString().Length).Trim().ToUpper() == tbx.Text.ToUpper().Trim())
{
dv.RowFilter = "Convert(" + ds.Columns[i].ColumnName + ", 'System.String') like '" + tbx.Text + "%'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
ViewState["m"] = 1;
paging(dt,1);
}
protected void gv_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dt = (DataTable)ViewState["dt"];
DataView dv = new DataView();
dv = dt.DefaultView;
DataTable dt3 = new DataTable();
for (i = 0; i < dt.Columns.Count; i++)
{
dt3.Columns.Add(dt.Columns[i].ColumnName, typeof(string));
}
if (Convert.ToInt32(ViewState["s"]) == 0)
{
dv.Sort = "" + e.SortExpression.ToString() + " ASC";
ViewState["s"] = 1;
}
else
{
dv.Sort = "" + e.SortExpression.ToString() + " DESC";
ViewState["s"] = 0;
}
DataRow dr;
for (i = 0; i < dv.Count; i++)
{
dr = dt3.NewRow();
for (j = 0; j < dt.Columns.Count; j++)
{
dr[dt.Columns[j].ColumnName.ToString()] = dv[i][j].ToString();
}
dt3.Rows.Add(dr);
}
paging(dt3,Convert.ToInt32( ViewState["m"]));
}
protected void gv_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Visible = false;
e.Row.Cells[3].Visible = false;
}
protected void lbtn_Click(object sender, EventArgs e)
{
LinkButton lbt = (LinkButton)sender;
if (this.popup != null)
{
this.popup(lbt.CommandArgument.ToString());
}
}
protected void im_Click1(object sender, ImageClickEventArgs e)
{
for (i = 0; i < gv.Rows.Count; i++)
{
if (((CheckBox)gv.Rows[i].FindControl("cb")).Checked)
{
s = s + ((LinkButton)gv.Rows[i].FindControl("lbtn")).CommandArgument.ToString() + ",";
}
}
s = s.Substring(0, s.LastIndexOf(','));
obj1.TABLENAME = ViewState["tbn"].ToString();
obj1.SCHEMA = ViewState["scm"].ToString();
obj1.GRIDEHEADER = ViewState["pk"].ToString();
obj1.COLNAME = (ArrayList)ViewState["clm"];
lbheader.Text = obj1.GRIDEHEADER.ToString() + " : ";
UERPManagement.GetInstance.delete(obj1, s);
DataTable ds1 = new DataTable();
ds1 = UERPManagement.GetInstance.UCUGrideviewbusiness(obj1);
ViewState["ds1"] = ds1;
ViewState["dt"] = ds1;
paging(((DataTable)ViewState["dt"]), Convert.ToInt32(ViewState["m"]));
}
protected void lbtn1_Click(object sender, EventArgs e)
{
LinkButton lbtt = (LinkButton)sender;
DataTable dt = (DataTable)ViewState["dt"];
DataView dv = new DataView();
dv = dt.DefaultView;
DataTable dt3 = new DataTable();
for (i = 0; i < dt.Columns.Count; i++)
{
dt3.Columns.Add(dt.Columns[i].ColumnName, typeof(string));
}
if (Convert.ToInt32(ViewState["s"]) == 0)
{
dv.Sort = "" + lbtt.Text + " ASC";
ViewState["s"] = 1;
}
else
{
dv.Sort = "" + lbtt.Text + " DESC";
ViewState["s"] = 0;
}
DataRow dr;
for (i = 0; i < dv.Count; i++)
{
dr = dt3.NewRow();
for (j = 0; j < dt.Columns.Count; j++)
{
dr[dt.Columns[j].ColumnName.ToString()] = dv[i][j].ToString();
}
dt3.Rows.Add(dr);
}
paging(dt3, Convert.ToInt32(ViewState["m"]));
}
}
}
this store procedure for fetching data.
ALTER PROCEDURE UCUGrideview
(
@pass varchar(max)
)
AS
begin
set nocount on
exec(@pass)
set nocount off
end
this store procedure for delete record
ALTER PROCEDURE UCUGrideviewDelete
(
@TABLE varchar(50),
@COLUMNNAME varchar(50),
@SCHEMA varchar(50),
@VALUE varchar(max)
)
AS
SET NOCOUNT ON
DECLARE @sql varchar(max)
begin
set @sql=('UPDATE '+@SCHEMA+'.'+@TABLE+' SET Is_Active=0 where '+@COLUMNNAME+' in('+@VALUE+')')
exec(@sql)
SET NOCOUNT OFF
end
DAL code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace .DataAccessLayer
{
public partial class UERPDataAccess
{
DataTable dt = new DataTable();
public void delete(UCUGrideview obj,string value)
{
SqlCommand cm = new SqlCommand("UCUGrideviewDelete");
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.AddWithValue("@TABLE", obj.TABLENAME);
cm.Parameters.AddWithValue("@COLUMNNAME", obj.COLNAME[0].ToString());
cm.Parameters.AddWithValue("@SCHEMA", obj.SCHEMA);
cm.Parameters.AddWithValue("@VALUE", value);
ExecuteStoredProcedure(cm);
}
public DataTable UCUGrideviewdata(UCUGrideview obj)
{
int i;
string s = string.Empty;
string ss = string.Empty;
SqlCommand cm = new SqlCommand("UCUGrideview");
cm.CommandType = CommandType.StoredProcedure;
string[] t = obj.COLNAME[0].ToString().Split('=');
if (t[0].Trim() == "*")
{
ss = "select * from " + obj.SCHEMA.ToString() + "." + obj.TABLENAME.ToString() + " where Is_Active=1";
}
else
{
if (t.GetLength(0) > 1)
{
for (i = 0; i < obj.COLNAME.Count; i++)
{
string[] tt = obj.COLNAME[i].ToString().Split('=');
s = s + tt[0].ToString() + " " + tt[1].ToString() + ",";
}
ss = "select " + s.Substring(0, s.LastIndexOf(',')) + " from " + obj.SCHEMA.ToString() + "." + obj.TABLENAME.ToString() + " where Is_Active=1";
}
else
{
for (i = 0; i < obj.COLNAME.Count; i++)
s = s + obj.COLNAME[i].ToString() + ",";
ss = "select " + s.Substring(0, s.LastIndexOf(',')) + " from " + obj.SCHEMA.ToString() + "." + obj.TABLENAME.ToString() + " where Is_Active=1";
}
}
cm.Parameters.AddWithValue("@pass", ss);
dt.Clear();
dt.Reset();
dt = ExecuteGetDataTable(cm);
return dt;
}
}
}
user control design code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCUGrideview.ascx.cs" Inherits="Website.App_WebControls.UAMS_UserControls.UCUGrideview" %>
<script language="javascript" type="text/javascript">
function SelectAllCheckboxes1(chk) {
var i = 0;
$('#<%=gv.ClientID%>').find("input:checkbox").each(function () {
if (this != chk) {
i = i + 1;
if (chk.checked)
this.checked = true;
else {
this.checked = false;
i = 0;
}
}
});
document.getElementById('<%=sp.ClientID%>').innerHTML = "(" + i + " selected" + ")";
}
function SelectAllCheckboxes2()
{
$.each($('#<%=gv.ClientID%>').find("tr"), function ()
{
var chk = $(this).find("th:first").find(":checkbox");
chk.attr("checked",false)
});
var m = $('#<%=gv.ClientID%>').find("tr").length
var n = 0;
$('#<%=gv.ClientID%>').find("input:checkbox").each(function () {
if (this.checked) {
n = n + 1;
}
});
document.getElementById('<%=sp.ClientID%>').innerHTML = "(" + n + " selected" + ")";
if ((parseInt(m) - 1) == parseInt(n))
$('#<%=gv.ClientID%>').find("th:first").find(":checkbox").attr("checked", true)
}
function x() {
document.getElementById('<%=tbx.ClientID %>').value = "";
}
function y() {
if( document.getElementById('<%=tbx.ClientID %>').value =="")
document.getElementById('<%=tbx.ClientID %>').value='Search for records'
}
function del()
{
var i = 0;
$('#<%=gv.ClientID%>').find("input:checkbox").each(function () {
if (this.checked)
{
i = 1;
}
});
if (i == 0) {
alert('Please select atleast one item.')
return false
}
else {
var j = confirm('Do you want to delete it.?');
if (j == true)
return true;
else
return false;
}
}
function z() {
if (document.getElementById('<%=tbx.ClientID %>').value == 'Search for records') {
alert('Please enter a search item.')
return false;
}
}
function xx() {
var m = "~`!@#$%^&*()-_+={}[]\|:;\'\"<>,.?/"
var n = document.getElementById('<%=tbx.ClientID %>')
for (var i = 0; i < n.value.length; i++)
if (m.search(n.value.charAt(i)) != -1)
alert('You can not enter special charecter.');
}
</script>
<div style="height:365px;width:99.8%;overflow:auto;border:1px solid #C1CDCD">
<table width="100%">
<tr><td colspan="2"><table width="100%"><tr><td align="left" style="width:30%">
<asp:Label ID="lbheader" runat="server" ForeColor="#666666"></asp:Label></td><td align="center" style="width:40%"><asp:TextBox ID="tbx" Width="200"
runat="server" ForeColor="#666666" onfocus="x()" onkeyup="xx()" onblur="y()">Search for records</asp:TextBox> <asp:ImageButton
ID="imbs" runat="server" ImageUrl="~/images/SearchButton.gif"
onclick="imbs_Click" OnClientClick="return z()" /></td><td align="right" style="width:30%">
<asp:ImageButton ID="im" onclientclick="return del()" runat="server"
ImageUrl="~/Uimages/delete_list.png" onclick="im_Click1" /></td></tr></table></td></tr>
<tr><td colspan="2" align="center"><asp:Label ID="message1" runat="server"
Visible="False" ForeColor="#666666"></asp:Label>
<asp:GridView ID="gv" runat="server" Width="100%" AllowSorting="True"
onsorting="gv_Sorting" onrowcreated="gv_RowCreated">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="hcb" onclick="SelectAllCheckboxes1(this)" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="cb" onclick="SelectAllCheckboxes2()" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="lbtn1" runat="server" onclick="lbtn1_Click" ></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lbtn" runat="server" onclick="lbtn_Click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Underline="true" />
</asp:GridView>
</td></tr>
<tr><td><asp:Label ID="lb2" runat="server" ForeColor="#666666"></asp:Label> <span runat="server"
id="sp" style="color: #666666">(0 selected)</span></td><td align="right">
<asp:ImageButton ID="imb" ImageUrl="~/image/PaginFirst.gif" runat="server"
onclick="imb_Click" ToolTip="First" /> <asp:ImageButton ID="imb2" ImageUrl="~/image/PaginPre.gif" runat="server"
onclick="imb2_Click" ToolTip="Previous" />
<asp:Label id="lb" runat="server" ForeColor="#666666"></asp:Label>
<asp:ImageButton ID="imb1"
ImageUrl="~/image/PaginNext.gif" ToolTip="Next" runat="server" onclick="imb1_Click" /> <asp:ImageButton ID="imb3"
ImageUrl="~/image/PaginLast.gif" ToolTip="Last" runat="server" onclick="imb3_Click" /></td></tr>
<tr><td colspan="2">
<table width="100%" style=" color:#808080"><tr>
<td><asp:LinkButton ID="lbt" runat="server" Text="All" ToolTip="View all records" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton1" runat="server" Text="#" ToolTip="View records that start with number from 0 to 9" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton2" runat="server" Text="A" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton3" runat="server" Text="B" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton4" runat="server" Text="C" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton5" runat="server" Text="D" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton6" runat="server" Text="E" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton7" runat="server" Text="F" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton8" runat="server" Text="G" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton9" runat="server" Text="H" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton10" runat="server" Text="I" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton11" runat="server" Text="J" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton12" runat="server" Text="K" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton13" runat="server" Text="L" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton14" runat="server" Text="M" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton15" runat="server" Text="N" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton16" runat="server" Text="O" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton17" runat="server" Text="P" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton18" runat="server" Text="Q" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton19" runat="server" Text="R" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton20" runat="server" Text="S" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton21" runat="server" Text="T" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton22" runat="server" Text="U" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton23" runat="server" Text="V" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton24" runat="server" Text="W" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton25" runat="server" Text="X" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton26" runat="server" Text="Y" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
<td><asp:LinkButton ID="LinkButton27" runat="server" Text="Z" ToolTip="View records that start wtih this letter" Font-Underline="false" onclick="lbt_Click"></asp:LinkButton></td>
</tr></table>
</td></tr>
</table>
</div>
user control c# code
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swash.Objects;
using Swash.BusinessLayer;
using System.Data;
namespace Website.App_WebControls.UAMS_UserControls
{
public partial class UCUGrideview : System.Web.UI.UserControl
{
#region
int i, j, k, l, m, sk = 0,tk=0,p;
string s = string.Empty;
Swash.Objects.UCUGrideview obj1 = new Swash.Objects.UCUGrideview();
#endregion
public delegate void open(string s);
public event open popup;
protected void Page_Load(object sender, EventArgs e)
{
}
public void view(Swash.Objects.UCUGrideview obj)
{
ViewState["s"] = 0;
ViewState["ps"] = 10;
ViewState["m"] = 1;
ViewState["st"] = 1;
ViewState["pz"] = 1;
DataTable ds = new DataTable();
ds.Clear();
ds.Reset();
ds = UERPManagement.GetInstance.UCUGrideviewbusiness(obj);
ViewState["pk"] = obj.GRIDEHEADER.ToString();
ViewState["tbn"] = obj.TABLENAME.ToString();
ViewState["scm"] = obj.SCHEMA.ToString();
ViewState["clm"] = obj.COLNAME;
ViewState["ds1"] = ds;
paging(ds,1);
lbheader.Text = obj.GRIDEHEADER.ToString() + " : ";
//gv.DataKeyNames = new string[] { obj.PRIMARYKEYCOLNAME.ToString()};
}
void paging(DataTable dt, int x)
{
if (dt.Rows.Count == 0)
{
gv.DataSource = null;
gv.DataBind();
message1.Visible = true;
message1.Text = "No records available that starting with this letter. ";
lb.Visible = false;
lb2.Visible = false;
imb.Visible = false;
imb1.Visible = false;
imb2.Visible = false;
imb3.Visible = false;
sp.Visible = false;
im.Visible = false;
tbx.Text = "Search for records";
tbx.Visible = false;
imbs.Visible = false;
return;
}
else
{
lb.Visible = true;
lb2.Visible = true;
imb.Visible = true;
imb1.Visible = true;
imb2.Visible = true;
imb3.Visible = true;
sp.Visible = true;
message1.Visible = false;
im.Visible = true;
tbx.Visible = true;
imbs.Visible = true;
}
i = x;
DataTable dt2 = new DataTable();
dt2.Clear();
dt2.Reset();
ViewState["dt"] = dt;
tk = Convert.ToInt32(ViewState["ps"]);
double yy = Math.Ceiling(Convert.ToDouble(dt.Rows.Count) / Convert.ToDouble(ViewState["ps"]));
if (x == 1)
{
sk = 0;
}
else
{
if (x >= Convert.ToInt32(yy))
{
if (dt.Rows.Count % Convert.ToInt32(ViewState["ps"]) == 0)
{
x = Convert.ToInt32(yy);
sk = ((Convert.ToInt32(ViewState["ps"]) * x) - Convert.ToInt32(ViewState["ps"]));
}
else
{
x = Convert.ToInt32(yy);
sk = ((Convert.ToInt32(ViewState["ps"]) * x) - Convert.ToInt32(ViewState["ps"]));
tk = (dt.Rows.Count) - sk;
}
}
else
sk = ((Convert.ToInt32(ViewState["ps"]) * x) - Convert.ToInt32(ViewState["ps"]));
}
dt2 = ((DataTable)ViewState["dt"]).AsEnumerable().Skip(sk).Take(tk).CopyToDataTable();
if (i > Convert.ToInt32(yy))
{
i = Convert.ToInt32(yy);
ViewState["m"] = i;
}
lb.Text = "Page " + i.ToString();
string st = "";
if (tk > dt2.Rows.Count)
st = dt2.Rows.Count.ToString();
else
st = tk.ToString();
if(sk==0)
lb2.Text = 1 + "-" + st.ToString() + " of " + ((DataTable)ViewState["dt"]).Rows.Count;
else
lb2.Text =(1+sk).ToString() + "-" + st.ToString() + " of " + ((DataTable)ViewState["dt"]).Rows.Count;
gv.DataSource = dt2;
gv.DataBind();
for (int m = 0; m < dt2.Rows.Count; m++)
{
((LinkButton)gv.Rows[m].FindControl("lbtn")).CommandArgument = dt2.Rows[m][0].ToString();
((LinkButton)gv.Rows[m].FindControl("lbtn")).Text = dt2.Rows[m][1].ToString();
}
((LinkButton)gv.HeaderRow.FindControl("lbtn1")).Text = dt.Columns[1].ColumnName.ToString();
}
protected void lbt_Click(object sender, EventArgs e)
{
LinkButton lbtn=(LinkButton)sender;
DataTable ds = new DataTable();
ds.Clear();
ds.Reset();
ds = ((DataTable)ViewState["ds1"]);
DataTable dt = new DataTable();
DataView dv = new DataView();
dv = ds.DefaultView;
for (i = 0; i < ds.Columns.Count; i++)
{
dt.Columns.Add(ds.Columns[i].ColumnName, typeof(string));
}
switch (lbtn.Text)
{
case "All":
dt = ds;
break;
case "#":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
for (p = 0; p < 10; p++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= p.ToString().Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == p.ToString().Trim())
{
dv.RowFilter = "Convert(" + ds.Columns[i].ColumnName + ", 'System.String') like '" + p + "*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
}
break;
case "A":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "A".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "A")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'A*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "B":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "B".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "B")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'B*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "C":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "C".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "C")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'C*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "D":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "D".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "D")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'D*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "E":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "E".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "E")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'E*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "F":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "F".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "F")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'F*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "G":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "G".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "G")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'G*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "H":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "H".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "H")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'H*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "I":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "I".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "I")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'I*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "J":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "J".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "J")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'J*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "K":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "K".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "K")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'K*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "L":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "L".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "L")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'L*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "M":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "M".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "M")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'M*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "N":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "N".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "N")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'N*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "O":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "O".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "O")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'O*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
}
break;
}
}
}
break;
case "P":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "A".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "P")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'P*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "Q":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "Q".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "Q")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'Q*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "R":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "R".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "R")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'R*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "S":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "S".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "S")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'S*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "T":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "T".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "T")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'T*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "U":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "U".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "U")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'U*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "V":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "V".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "V")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'V*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "W":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "W".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "W")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'W*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "X":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "X".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "X")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'X*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
case "Y":
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "Y".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "Y")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'Y*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
default:
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= "Z".Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, 1).Trim().ToUpper() == "Z")
{
dv.RowFilter = "" + ds.Columns[i].ColumnName + " like 'Z*'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
break;
}
ViewState["m"] = 1;
paging(dt, 1);
}
protected void imb_Click(object sender, ImageClickEventArgs e)
{
ViewState["m"] = 1;
paging((DataTable)ViewState["dt"],Convert.ToInt32(ViewState["m"]));
}
protected void imb1_Click(object sender, ImageClickEventArgs e)
{
ViewState["m"] = Convert.ToInt32(ViewState["m"]) + 1;
paging((DataTable)ViewState["dt"], Convert.ToInt32(ViewState["m"]));
}
protected void imb2_Click(object sender, ImageClickEventArgs e)
{
ViewState["m"] = Convert.ToInt32(ViewState["m"]) - 1;
if (Convert.ToInt32(ViewState["m"]) <= 0)
ViewState["m"] = 1;
paging((DataTable)ViewState["dt"], Convert.ToInt32(ViewState["m"]));
}
protected void imb3_Click(object sender, ImageClickEventArgs e)
{
double yy = Math.Ceiling(Convert.ToDouble(((DataTable)ViewState["dt"]).Rows.Count) / Convert.ToDouble(ViewState["ps"]));
ViewState["m"] = Convert.ToInt32(yy);
paging((DataTable)ViewState["dt"], Convert.ToInt32(ViewState["m"]));
}
protected void imbs_Click(object sender, ImageClickEventArgs e)
{
DataTable ds = new DataTable();
ds.Clear();
ds.Reset();
ds = ((DataTable)ViewState["ds1"]);
DataTable dt = new DataTable();
DataView dv = new DataView();
dv = ds.DefaultView;
for (i = 0; i < ds.Columns.Count; i++)
{
dt.Columns.Add(ds.Columns[i].ColumnName, typeof(string));
}
for (i = 0; i < ds.Columns.Count; i++)
{
for (j = 0; j < ds.Rows.Count; j++)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Length >= tbx.Text.Length)
{
if (ds.Rows[j][ds.Columns[i].ColumnName].ToString().Substring(0, tbx.Text.ToString().Length).Trim().ToUpper() == tbx.Text.ToUpper().Trim())
{
dv.RowFilter = "Convert(" + ds.Columns[i].ColumnName + ", 'System.String') like '" + tbx.Text + "%'";
DataRow dr;
for (k = 0; k < dv.Count; k++)
{
dr = dt.NewRow();
for (l = 0; l < ds.Columns.Count; l++)
{
dr[ds.Columns[l].ColumnName] = dv[k][l].ToString();
}
if (dt.Rows.Count == 0)
dt.Rows.Add(dr);
else
{
int n = 0;
for (m = 0; m < dt.Rows.Count; m++)
if (dt.Rows[m][0].ToString().Trim() == dr[0].ToString().Trim())
n = 1;
if (n == 0)
dt.Rows.Add(dr);
}
}
break;
}
}
}
}
ViewState["m"] = 1;
paging(dt,1);
}
protected void gv_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dt = (DataTable)ViewState["dt"];
DataView dv = new DataView();
dv = dt.DefaultView;
DataTable dt3 = new DataTable();
for (i = 0; i < dt.Columns.Count; i++)
{
dt3.Columns.Add(dt.Columns[i].ColumnName, typeof(string));
}
if (Convert.ToInt32(ViewState["s"]) == 0)
{
dv.Sort = "" + e.SortExpression.ToString() + " ASC";
ViewState["s"] = 1;
}
else
{
dv.Sort = "" + e.SortExpression.ToString() + " DESC";
ViewState["s"] = 0;
}
DataRow dr;
for (i = 0; i < dv.Count; i++)
{
dr = dt3.NewRow();
for (j = 0; j < dt.Columns.Count; j++)
{
dr[dt.Columns[j].ColumnName.ToString()] = dv[i][j].ToString();
}
dt3.Rows.Add(dr);
}
paging(dt3,Convert.ToInt32( ViewState["m"]));
}
protected void gv_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Visible = false;
e.Row.Cells[3].Visible = false;
}
protected void lbtn_Click(object sender, EventArgs e)
{
LinkButton lbt = (LinkButton)sender;
if (this.popup != null)
{
this.popup(lbt.CommandArgument.ToString());
}
}
protected void im_Click1(object sender, ImageClickEventArgs e)
{
for (i = 0; i < gv.Rows.Count; i++)
{
if (((CheckBox)gv.Rows[i].FindControl("cb")).Checked)
{
s = s + ((LinkButton)gv.Rows[i].FindControl("lbtn")).CommandArgument.ToString() + ",";
}
}
s = s.Substring(0, s.LastIndexOf(','));
obj1.TABLENAME = ViewState["tbn"].ToString();
obj1.SCHEMA = ViewState["scm"].ToString();
obj1.GRIDEHEADER = ViewState["pk"].ToString();
obj1.COLNAME = (ArrayList)ViewState["clm"];
lbheader.Text = obj1.GRIDEHEADER.ToString() + " : ";
UERPManagement.GetInstance.delete(obj1, s);
DataTable ds1 = new DataTable();
ds1 = UERPManagement.GetInstance.UCUGrideviewbusiness(obj1);
ViewState["ds1"] = ds1;
ViewState["dt"] = ds1;
paging(((DataTable)ViewState["dt"]), Convert.ToInt32(ViewState["m"]));
}
protected void lbtn1_Click(object sender, EventArgs e)
{
LinkButton lbtt = (LinkButton)sender;
DataTable dt = (DataTable)ViewState["dt"];
DataView dv = new DataView();
dv = dt.DefaultView;
DataTable dt3 = new DataTable();
for (i = 0; i < dt.Columns.Count; i++)
{
dt3.Columns.Add(dt.Columns[i].ColumnName, typeof(string));
}
if (Convert.ToInt32(ViewState["s"]) == 0)
{
dv.Sort = "" + lbtt.Text + " ASC";
ViewState["s"] = 1;
}
else
{
dv.Sort = "" + lbtt.Text + " DESC";
ViewState["s"] = 0;
}
DataRow dr;
for (i = 0; i < dv.Count; i++)
{
dr = dt3.NewRow();
for (j = 0; j < dt.Columns.Count; j++)
{
dr[dt.Columns[j].ColumnName.ToString()] = dv[i][j].ToString();
}
dt3.Rows.Add(dr);
}
paging(dt3, Convert.ToInt32(ViewState["m"]));
}
}
}
No comments:
Post a Comment