关于google
下面的代码怎么让datalist绑定到的搜索结果不用listbox,并且在datalist有超连接,还有就是请问怎么得到总页数并进行分页。请高手指点一下,谢谢。private void Button1_Click(object sender, System.EventArgs e)
{
try
{
sKey="R1SnlcZQFHIBYlBCYdip3j1ERCvueU2Z";
localhost.GoogleSearchService s=new localhost.GoogleSearchService();
localhost.GoogleSearchResult r=s.doGoogleSearch(sKey, TextBox1.Text,
0, 10, false, "", false, "", "", "");
localhost.ResultElement[] re=r.resultElements;
this.ListBox1.Items.Clear();
for (int i=0;i<re.Length;i++)
{ this.ListBox1.Items.Add((re[i].title));
this.ListBox1.Items.Add((re[i].URL));
}
}
catch(Exception eee)
{
}
private void ListBox1_DoubleClick(object sender, System.EventArgs e)
{
try
{
String url;
url=ListBox1.SelectedItem.Text ;
Process p = Process.Start(@url);
}
catch (Exception ee)
{
}
}
}
下面的代码怎么让datalist绑定到的搜索结果不用listbox,并且在datalist有超连接,还有就是请问怎么得到总页数并进行分页。请高手指点一下,谢谢。private void Button1_Click(object sender, System.EventArgs e)
{
try
{
sKey="R1SnlcZQFHIBYlBCYdip3j1ERCvueU2Z";
localhost.GoogleSearchService s=new localhost.GoogleSearchService();
localhost.GoogleSearchResult r=s.doGoogleSearch(sKey, TextBox1.Text,
0, 10, false, "", false, "", "", "");
localhost.ResultElement[] re=r.resultElements;
this.ListBox1.Items.Clear();
for (int i=0;i<re.Length;i++)
{ this.ListBox1.Items.Add((re[i].title));
this.ListBox1.Items.Add((re[i].URL));
}
}
catch(Exception eee)
{
}
private void ListBox1_DoubleClick(object sender, System.EventArgs e)
{
try
{
String url;
url=ListBox1.SelectedItem.Text ;
Process p = Process.Start(@url);
}
catch (Exception ee)
{
}
}
}
解决方案 »
- GridView内部DropDownList联动
- 请教个关于数据初始化的问题
- 如何实现密码框大写提示功能
- 我这里有一个播放器,我如何播放器动态的传递路径 如题
- 请教如何使客户端不能缓存.swf文件?即只可以用浏览器浏览而保护flash文件不被下载? --- 实在没分了,最后的10分
- web.config配置冲突,如何解决?急!!!
- asp.net master page 问题
- vs2005简单问题
- URL 正则表达式问题
- 导入命名空间的问题````大家请帮帮忙````
- 我在VS2005下面用ASP。NET,C#做了个网站,朋友说现在提供的空间都不支持的?
- 谁能提供一些c#写的实例给参考一下,要用cs文件
<table width="100%" border="0">
<tr>
<td>
<asp:label id="lblCurrentPage" runat="server"></asp:label></td>
</tr>
<tr>
<td>
<asp:button id="cmdPrev" runat="server" text=" <上一页"></asp:button>
<asp:button id="cmdNext" runat="server" text="下一页> "></asp:button></td>
</tr>
</table>
<table width="100%">
<asp:DataList id="DataList1" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:HyperLink id="HyperLink1" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "url") %>' runat="server">
<%# DataBinder.Eval(Container.DataItem, "title") %>
</asp:HyperLink></td>
</tr>
</ItemTemplate>
</asp:DataList>
</table>
-----------------------------------------------------------
.aspx.cs文件中:protected System.Web.UI.WebControls.Label lblCurrentPage;
protected System.Web.UI.WebControls.Button cmdPrev;
protected System.Web.UI.WebControls.Button cmdNext;
protected System.Web.UI.WebControls.DataList DataList1;private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BindList();
}
}void BindList()
{
ICollection collectionSource = this.CreateDataSource();
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = collectionSource;
objPds.AllowPaging = true;
objPds.PageSize = 3; objPds.CurrentPageIndex = CurrentPage; lblCurrentPage.Text = "页次: " + (CurrentPage + 1).ToString() + " of "
+ objPds.PageCount.ToString(); cmdPrev.Enabled = !objPds.IsFirstPage;
cmdNext.Enabled = !objPds.IsLastPage; DataList1.DataSource= objPds;
DataList1.DataBind();
}ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr; dt.Columns.Add(new DataColumn("title", typeof(string)));
dt.Columns.Add(new DataColumn("url", typeof(string))); for (int i = 0; i < 9; i++)
{
dr = dt.NewRow(); dr[0] = "this is title " + i;
dr[1] = "http://www." + i.ToString() + ".com"; dt.Rows.Add(dr);
} DataView dv = new DataView(dt);
return dv;
}public int CurrentPage
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int) o;
} set
{
this.ViewState["_CurrentPage"] = value;
}
}private void cmdPrev_Click(object sender, System.EventArgs e)
{
CurrentPage -= 1;
BindList();
}private void cmdNext_Click(object sender, System.EventArgs e)
{
CurrentPage += 1;
BindList();
}#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.cmdPrev.Click += new System.EventHandler(this.cmdPrev_Click);
this.cmdNext.Click += new System.EventHandler(this.cmdNext_Click);
this.Load += new System.EventHandler(this.Page_Load);}
#endregion