Im selecting all records from no of columns from 5 tables by joining.
aftre bind it to gridview want to search records on demand on columns without go to server?
so how to to do that?by xml or datatable or dataset then how?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Azaad AbbasPosted Apr 14, 2015, 5:10 AM
Azaad AbbasPosted Apr 6, 2015, 2:07 AM
Khargesh RajputPosted Apr 6, 2015, 2:04 AM
Dawood AbbasPosted Apr 6, 2015, 1:43 AM
Dawood AbbasPosted Apr 6, 2015, 1:25 AM
Gowtham RajamanickamPosted Apr 5, 2015, 1:31 AM
Khargesh RajputPosted Apr 4, 2015, 8:43 AM
Azaad AbbasPosted Apr 4, 2015, 8:16 AM
public DataSet Ds
Azaad AbbasPosted Mar 31, 2015, 4:59 AM
Khargesh RajputPosted Mar 31, 2015, 4:58 AM
and on event OnPageIndexChanging
grdSearch.PageIndex = e.NewPageIndex;
fncBindGrid();// this is function where You write the code on page load to bind gridview
Azaad AbbasPosted Mar 31, 2015, 4:45 AM
Khargesh RajputPosted Mar 31, 2015, 4:36 AM
Azaad AbbasPosted Mar 31, 2015, 4:19 AM
but here for paging need IDataReader coz its coming from sql query if bind dataset then cant do paging.
Khargesh RajputPosted Mar 31, 2015, 4:06 AM
You can try to check
otherwise use dataset
Azaad AbbasPosted Mar 31, 2015, 2:59 AM
Khargesh RajputPosted Mar 31, 2015, 2:43 AM
DataSet dsAcc = new DataSet();
you have created object here
instead you
declare dataset globally in viewstate as
public DataSet Ds
{
get
{
object temp = ViewState["Ds"];
return temp == null ? null : temp as DataSet;
}
set
{
ViewState["Ds"] = value;
}
}
Azaad AbbasPosted Mar 31, 2015, 2:38 AM
connection.Open();
command = new SqlCommand();
command.CommandText = "sp_Get_CustInfoSerach";
command.CommandType = CommandType.StoredProcedure;
command.Connection = connection;
command.Parameters.AddWithValue("@PageIndex", pageIndex);
command.Parameters.AddWithValue("@PageSize", int.Parse(ddlPaging.SelectedValue));
command.Parameters.Add("@RecordCount", SqlDbType.Int, 4);
command.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
SqlParameter outParam = command.Parameters.Add("@bal", SqlDbType.Float);
outParam.Direction = ParameterDirection.Output;
SqlDataAdapter daAcc = new SqlDataAdapter(command);
DataSet dsAcc = new DataSet();
daAcc.Fill(dsAcc);
Khargesh RajputPosted Mar 31, 2015, 2:34 AM
Ds = objdal.FillDataSet(CommandType.StoredProcedure, "sp_getTopic");
for a example to show to bind dataset
you have to write your query/procedure to bind dataset
I was using DAL class and methods to fill dataset from database and bind dataset to gridview
Azaad AbbasPosted Mar 31, 2015, 2:19 AM
/*Here 'objdal' of which object where its declared??*/
Khargesh RajputPosted Mar 31, 2015, 2:15 AM
if (!Page.IsPostBack)
{
//code to bind
}
Azaad AbbasPosted Mar 31, 2015, 2:13 AM
bind gridview on postback check /*MEAN BEFORE !iSpOSTbACK CHECK? OR IN SIDE?*/
Ds = objdal.FillDataSet(CommandType.StoredProcedure, "sp_getTopic"); /*WHAT IS objdal?*/
Khargesh RajputPosted Mar 26, 2015, 6:13 AM
as
public DataSet Ds
{
get
{
object temp = ViewState["Ds"];
return temp == null ? null : temp as DataSet;
}
set
{
ViewState["Ds"] = value;
}
}
step 2
bind gridview on postback check
Ds = objdal.FillDataSet(CommandType.StoredProcedure, "sp_getTopic");
if (Ds.Tables[0].Rows.Count > 0)
{
grdSearch.DataSource = Ds.Tables[0];
grdSearch.DataBind();
}
}
step 3
on search buttonclick
string strFieldNm;
strFieldNm = ddl_Search.Text.Trim();
if (strFieldNm == "Category")
{
strFieldNm = "category_name";
}
if (strFieldNm == "Class")
{
strFieldNm = "class_name";
}
if (txt_Search.Text.Trim().Length > 0)
{
DataTable dt = new DataTable();
dt = Ds.Tables[0];
dt.DefaultView.RowFilter = "Convert([" + strFieldNm + "],'System.String') Like '" + txt_Search.Text.Trim().Replace("'", "''") + "%' ";
grdSearch.DataSource = dt;
grdSearch.DataBind();
}
here i have search by dropdown(by columnname of database you want to search) and textbox for keyword you want to search
i have bind dropdown statically as
Category,Class and category_name,class_name are columnname from dataset
I hope It may help you