private DataView ShowDocbyid(string proid)
{
SqlConnection conn=new SqlConnection(connstring);
string str="select '"+proid+"' as ProjectID,(select Project.Name from Project where Project.ID='"+proid+"' group by Project.Name) as ProjectName, c.Name from ObjectDict c where c.ID in (select b.ObjectID from ActionNode b where b.ID in (select a.ActionNodeID from ProjectActionNode a where a.ProjectID ='"+proid+"')) ";
SqlCommand comm=new SqlCommand(str,conn);
conn.Open();
SqlDataAdapter da=new SqlDataAdapter(comm);
DataSet ds=new DataSet();
da.Fill(ds,"byid");
DataView dv=ds.Tables["byid"].DefaultView;
conn.Close();
return dv;
}
//显示该工程的文档信息byname;
private DataView ShowDocbyname( string proname)
{
SqlConnection conn=new SqlConnection(connstring);
string strproid="select ID from Project where Name='"+proname+"'";
conn.Open();
SqlCommand com=new SqlCommand(strproid,conn);
SqlDataReader dr=com.ExecuteReader();
DataTable dt=new DataTable("byname");
DataColumn dc1=new DataColumn("ProjectID",Type.GetType("System.String"));
DataColumn dc2=new DataColumn("ProjectName",Type.GetType("System.String"));
DataColumn dc3=new DataColumn("Name",Type.GetType("System.String"));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3); while(dr.Read())
{
SqlConnection newconn=new SqlConnection(connstring);
string str="select '"+dr["ID"].ToString()+"' as ProjectID,(select Project.Name from Project where Project.ID='"+dr["ID"].ToString()+"' group by Project.Name) as ProjectName, c.Name from ObjectDict c where c.ID in (select b.ObjectID from ActionNode b where b.ID in (select a.ActionNodeID from ProjectActionNode a where a.ProjectID ='"+dr["ID"].ToString()+"')) ";
newconn.Open();
SqlCommand newcom=new SqlCommand(str,newconn);
SqlDataAdapter newda=new SqlDataAdapter(newcom);
DataSet newds=new DataSet();
newda.Fill(newds,"row");
int i=newds.Tables["row"].Rows.Count;
for(int j=0;j<i;j++)
{
DataRow datarow=dt.NewRow();
for(int k=0;k<3;k++)
{
datarow[k]=newds.Tables["row"].Rows[j][k].ToString();
}
dt.Rows.Add(datarow);
} }
DataView dv=dt.DefaultView;
return dv;
}
private void byname_Click(object sender, System.EventArgs e)
{
}
}
我定义了两个函数,然后在点击byname按钮时,根据两个单选按钮,来选择给DataGrid绑定哪个函数的返回值,可是当发生分页时,页面就会刷新,绑定内容也没了.
这个问题咋解决呀!!????
请高手赐教!!!
谢谢!!!
{
SqlConnection conn=new SqlConnection(connstring);
string str="select '"+proid+"' as ProjectID,(select Project.Name from Project where Project.ID='"+proid+"' group by Project.Name) as ProjectName, c.Name from ObjectDict c where c.ID in (select b.ObjectID from ActionNode b where b.ID in (select a.ActionNodeID from ProjectActionNode a where a.ProjectID ='"+proid+"')) ";
SqlCommand comm=new SqlCommand(str,conn);
conn.Open();
SqlDataAdapter da=new SqlDataAdapter(comm);
DataSet ds=new DataSet();
da.Fill(ds,"byid");
DataView dv=ds.Tables["byid"].DefaultView;
conn.Close();
return dv;
}
//显示该工程的文档信息byname;
private DataView ShowDocbyname( string proname)
{
SqlConnection conn=new SqlConnection(connstring);
string strproid="select ID from Project where Name='"+proname+"'";
conn.Open();
SqlCommand com=new SqlCommand(strproid,conn);
SqlDataReader dr=com.ExecuteReader();
DataTable dt=new DataTable("byname");
DataColumn dc1=new DataColumn("ProjectID",Type.GetType("System.String"));
DataColumn dc2=new DataColumn("ProjectName",Type.GetType("System.String"));
DataColumn dc3=new DataColumn("Name",Type.GetType("System.String"));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3); while(dr.Read())
{
SqlConnection newconn=new SqlConnection(connstring);
string str="select '"+dr["ID"].ToString()+"' as ProjectID,(select Project.Name from Project where Project.ID='"+dr["ID"].ToString()+"' group by Project.Name) as ProjectName, c.Name from ObjectDict c where c.ID in (select b.ObjectID from ActionNode b where b.ID in (select a.ActionNodeID from ProjectActionNode a where a.ProjectID ='"+dr["ID"].ToString()+"')) ";
newconn.Open();
SqlCommand newcom=new SqlCommand(str,newconn);
SqlDataAdapter newda=new SqlDataAdapter(newcom);
DataSet newds=new DataSet();
newda.Fill(newds,"row");
int i=newds.Tables["row"].Rows.Count;
for(int j=0;j<i;j++)
{
DataRow datarow=dt.NewRow();
for(int k=0;k<3;k++)
{
datarow[k]=newds.Tables["row"].Rows[j][k].ToString();
}
dt.Rows.Add(datarow);
} }
DataView dv=dt.DefaultView;
return dv;
}
private void byname_Click(object sender, System.EventArgs e)
{
}
}
我定义了两个函数,然后在点击byname按钮时,根据两个单选按钮,来选择给DataGrid绑定哪个函数的返回值,可是当发生分页时,页面就会刷新,绑定内容也没了.
这个问题咋解决呀!!????
请高手赐教!!!
谢谢!!!
解决方案 »
- .net问题,控件在.aspx.cs中调不出来是怎么回事
- IBatisNet更新数据库是用的什么原理?请进,内详……
- 关于vs2008中wcf部署问题
- public abstract class LinqToSql<TContext> : Service where TContext : DataContext, new()怎么解释??
- 如何遍历Gridview中的Checkbox呢?检查被选中的checkbox的值呢?
- 用HTML编辑器的问题,如何过滤
- 如何读取Word文档中定义的变量?
- 一个有关DataList的问题,用过的高手请进!!在线等待答案,问题一经解决,立即给分!!
- 初学asp.net 问的都是初级的问题
- 自动保存表单
- 怎么样修改树型控件(treeview)结点的字体和背景颜色?好心人帮帮忙吧!
- 请教高手,另一个页面关闭时如果控制其它页面
sunnystar365(淡淡忧伤) 你说的重写一下是啥意思呀!??:)
大家知道如何刷新后还保持刷新前的状态吗!?:)
然后在要绑定的时候调用Sub不就可以了吗?大多都是这么写的。。
然后它可以做数据源,
但是DataGird有多页的时候,
用户点击下一页时,页面刷新,变量也就被清空了,
因为它是在单击时间中被赋的值呀!!!:(
因此数据不能被显示了呀!