帮忙解读C#代码
帮忙解读代码。。。SqlConnectionstrcon=newSqlConnection(System.Configuration.ConfigurationManag...
帮忙解读代码。。。
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlDataAdapter sda = new SqlDataAdapter("select a.*,b.companyname from tb_stock a left join tb_company b on a.companyid=b.id where type='" + type + "' and jz=0", strcon);
DataSet ds=new DataSet();
sda.Fill(ds, "Reckoning");
GridView1.DataSource = ds.Tables["Reckoning"];
GridView1.DataKeyNames = new string[]{"id"};
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString() ;
Response.Write("<script>window.open('open.aspx?id=" + id + "&type=" + Request["type"] + "&je=" + GridView1.Rows[e.NewSelectedIndex].Cells[3].Text + "&com="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text+"','','width=380,height=200,scrollbars=no')</script>");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
还有一些 没贴上来。 展开
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlDataAdapter sda = new SqlDataAdapter("select a.*,b.companyname from tb_stock a left join tb_company b on a.companyid=b.id where type='" + type + "' and jz=0", strcon);
DataSet ds=new DataSet();
sda.Fill(ds, "Reckoning");
GridView1.DataSource = ds.Tables["Reckoning"];
GridView1.DataKeyNames = new string[]{"id"};
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString() ;
Response.Write("<script>window.open('open.aspx?id=" + id + "&type=" + Request["type"] + "&je=" + GridView1.Rows[e.NewSelectedIndex].Cells[3].Text + "&com="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text+"','','width=380,height=200,scrollbars=no')</script>");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
还有一些 没贴上来。 展开
3个回答
展开全部
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]=//连接字符串);//连接命令
strcon.Open();//打开数据库
SqlDataAdapter sda = new SqlDataAdapter("select a.*,b.companyname from tb_stock a left join tb_company b on a.companyid=b.id where type='" + type + "' and jz=0", strcon);//执行sql语句
DataSet ds=new DataSet();//实例话dataset
sda.Fill(ds, "Reckoning");//将数据填充到dataset
GridView1.DataSource = ds.Tables["Reckoning"];//将数据绑定到GridView1
GridView1.DataKeyNames = new string[]{"id"};//数据主键
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;//总记录
this.bind();
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString() ;//取出ID
Response.Write("<script>window.open('open.aspx?id=" + id + "&type=" + Request["type"] + "&je=" + GridView1.Rows[e.NewSelectedIndex].Cells[3].Text + //"&com="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text+"','','width=380,height=200,scrollbars=no')</script>");//连接到XXX
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
strcon.Open();//打开数据库
SqlDataAdapter sda = new SqlDataAdapter("select a.*,b.companyname from tb_stock a left join tb_company b on a.companyid=b.id where type='" + type + "' and jz=0", strcon);//执行sql语句
DataSet ds=new DataSet();//实例话dataset
sda.Fill(ds, "Reckoning");//将数据填充到dataset
GridView1.DataSource = ds.Tables["Reckoning"];//将数据绑定到GridView1
GridView1.DataKeyNames = new string[]{"id"};//数据主键
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;//总记录
this.bind();
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString() ;//取出ID
Response.Write("<script>window.open('open.aspx?id=" + id + "&type=" + Request["type"] + "&je=" + GridView1.Rows[e.NewSelectedIndex].Cells[3].Text + //"&com="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text+"','','width=380,height=200,scrollbars=no')</script>");//连接到XXX
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
new sql连接 ,连接字符串从配置文件中读取
strcon.Open(); 打开
SqlDataAdapter sda = new SqlDataAdapter("select a.*,b.companyname from tb_stock a left join tb_company b on a.companyid=b.id where type='" + type + "' and jz=0", strcon);
声明adapter
DataSet ds=new DataSet();
sda.Fill(ds, "Reckoning");
用adapater填充dataset
GridView1.DataSource = ds.Tables["Reckoning"];
GridView1.DataKeyNames = new string[]{"id"};
GridView1.DataBind();
绑定gridview
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind(); 分页事件
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
选择事件
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString() ;
Response.Write("<script>window.open('open.aspx?id=" + id + "&type=" + Request["type"] + "&je=" + GridView1.Rows[e.NewSelectedIndex].Cells[3].Text + "&com="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text+"','','width=380,height=200,scrollbars=no')</script>");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
绑定事件,绑定gridview每一行的时候触发
if(e.Row.RowType==DataControlRowType.DataRow)
{如果在绑定数据行的时候执行, 控制显示的字符串长度,如果超过6个则截断并在末尾加上...
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
还有一些,请baidu或google
new sql连接 ,连接字符串从配置文件中读取
strcon.Open(); 打开
SqlDataAdapter sda = new SqlDataAdapter("select a.*,b.companyname from tb_stock a left join tb_company b on a.companyid=b.id where type='" + type + "' and jz=0", strcon);
声明adapter
DataSet ds=new DataSet();
sda.Fill(ds, "Reckoning");
用adapater填充dataset
GridView1.DataSource = ds.Tables["Reckoning"];
GridView1.DataKeyNames = new string[]{"id"};
GridView1.DataBind();
绑定gridview
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind(); 分页事件
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
选择事件
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString() ;
Response.Write("<script>window.open('open.aspx?id=" + id + "&type=" + Request["type"] + "&je=" + GridView1.Rows[e.NewSelectedIndex].Cells[3].Text + "&com="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text+"','','width=380,height=200,scrollbars=no')</script>");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
绑定事件,绑定gridview每一行的时候触发
if(e.Row.RowType==DataControlRowType.DataRow)
{如果在绑定数据行的时候执行, 控制显示的字符串长度,如果超过6个则截断并在末尾加上...
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
还有一些,请baidu或google
追问
还有一些 你给讲讲呗。。
给个QQ
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询