modify your sql statement
解决方案 »
- 有同学用过ASP.NET 3.5的图表控件嘛,有关饼图的问题请教
- 去空格函数
- 有人用过vs 2005 自带菜单menu控件吗??
- command对象的executerReader方法的参数?
- asp.net中调用vb编译的dll问题
- 各位大侠,小弟我有些问题实在不能解决,想问给位谁知道比尔盖茨的MSN或Email
- 如何动态在datagrid中加入列标题和列内容?
- 大家的程序是托控件的多,还是自己写得多?进者有分
- 各位大神,求指导啊!!!
- 为什么从帮助中COPY过来的SCRIPT到了ASPX中<>等符号都变了样子?
- 有经常在线的asp.net高手愿意指点一下我这个菜鸟吗?
- 如何实现先在客户端响应事件再到服务器里面响应事件?
<HeaderStyle Width="200px"></HeaderStyle>
</asp:HyperLinkColumn>
in datagrid's itemcommand event,write like this(if datagrid's view is same as dataset):
if(e.commandname=="lnk1")
{
int i=datagrid.currentpageindex*datagrid.pagesize+e.item.itemindex;
session["content_str"]=ds.tables[0].rows[i]["content"]
response.write("<script language=javascript>window.open("b.aspx");</script>")
}in b.aspx's page_load
response.write(session["content_str"].tostring());
in datagrid's itemcommand event,write like this(if datagrid's view is same as dataset):
if(e.commandname=="lnk1")
{
int i=datagrid.currentpageindex*datagrid.pagesize+e.item.itemindex;
session["content_str"]=ds.tables[0].rows[i]["content"].tostring();
response.write("<script language=javascript>window.open("b.aspx");</script>");
}in b.aspx's page_load
response.write(session["content_str"].tostring());
Dim ds As New DataSet()
Dim sc As New SqlCommand()
Dim dt As New DataTable()
Dim i As Integersc.commandtext="select * from table"
da.selectcommand=sc
da.fill(ds,"ss")
dt=ds.tables(0)datagrid1.datasource=dt
datagrid1.databind()for i=0 to dt.Columns.Count - 1
datagrid1.columns(i).itemstyle.width=dt.columns(i).maxlength
next这样可以控制datagrid的列宽是每列数据都完整显示,你作为链接列的数据就可用了。
protected string getchar( string str , int len )
{
if( str.Length > len )
{
str = str.Substring( 0, len );
str = str + "...";
return str;
}
else
{
return str;
}
}
页面中调用参考:<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink Text='<%# getchar(DataBinder.Eval(Container.DataItem,"title").ToString(),8)%>' ForeColor="#669999" runat="server"/>
</ItemTemplate> </asp:TemplateColumn>
可以在你的查询语句中直接处理SELECT
CASE WHEN len(field1) > 5 THEN '<a href=xxx.aspx>' + field1+'</a>' ELSE field1 END
FROM table
CASE WHEN len(field1) > 5 THEN '<a href=xxx.aspx>' + left(field1,10)+'…</a>' ELSE field1 END
FROM table
DataGrid在ItemDataCommand中,判断对应列的文字长度,如果大于固定的字符长度,则选取固定长度的text显示,再增加列事件“Title”,显示全部内容即可。
在datagrid的ItemCommand的事件中写:
if(e.CommandName.ToLower() == "openwindow")
{
Response.Write("<script>window.open('aaa.aspx');</script>");
}
在列的click中打开一个新窗口,把这个串的ID转过去,
在新窗口中通过这个id在到数据库中去取