帮忙解读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) + "…";
}

还有一些 没贴上来。
展开
 我来答
ch565097933
2011-04-08 · TA获得超过1044个赞
知道小有建树答主
回答量:825
采纳率:0%
帮助的人:515万
展开全部
就是一个简单的查询数据和控件自带的分页功能。
GridView1_SelectedIndexChanging事件中触发对话模式框,应该是用来显示对应的数据。
GridView1_RowDataBound,很明显,行绑定事件,当第二列和第三列中文本的长度超过6时截取文本的前6个字符+上'...'重新赋值给第二列以及第三列绑定。
追问
嗯嗯

还有一些代码

帮我下呗
追答
你在干什么啊,弄这些代码。
还有什么百度hi联系
kunjust
2011-04-08 · 超过25用户采纳过TA的回答
知道答主
回答量:156
采纳率:0%
帮助的人:61.4万
展开全部
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) + "…";
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友16ad9e1
2011-04-08 · TA获得超过774个赞
知道小有建树答主
回答量:477
采纳率:0%
帮助的人:509万
展开全部
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
追问
还有一些 你给讲讲呗。。
给个QQ
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式