解决方案 »
- 弹出式窗口不出来?
- 数据库求解· 怎么查询
- 请教一个线程问题(上传文件异步处理)
- 急:::: VS2005 日历控件如何重新触发DayRender,
- asp.net中的sessionState配置
- iframe 的 src 取值问题,请各位帮忙!解决问题,立马结帖!!!!
- 用asp.net写的网页在win98下面用IE5.0观看会出现乱码,请问如何处理?
- page_load发生在何时?
- 因开发需要,我是刚从CS转到BS来的,以后请大家多多关照
- Process.Start(@"C:\windows\system32\osk.exe")报错找不到指定文件
- mvc如何动态创建实体类
- 怎么在gridview读取出来每个数据旁边加checkbox
var str=str.empty;
for(int i=0;i<=temp.Count();i++)
{
str+="<div><img src='"+temp[i]+"' /></div>";
}
return str;
return str; 返回的str 要怎么弄呢
// 显示分类及一张照片
public DataSet ShowCategory()
{
SqlConnection conn = new SqlConnection(connstr);
string sqlstr = "select A.*,"
+ "(select count(*) from Photo B where B.CategoryID = A.ID) AS p_num,"
+ "(select top 1 C.url from Photo C where C.CategoryID = A.ID) AS url "
+ "from Photo_Category AS A "
+ "where A.C_Status = '公开' "
+ "and A.ID in "
+ "(select CategoryID from Photo)";
SqlDataAdapter da = new SqlDataAdapter(sqlstr,conn);
DataSet ds = new DataSet();
try
{
conn.Open();
da.Fill(ds,"P_Category");
}
catch(Exception ex)
{
throw new Exception(ex.Message,ex);
}
finally
{
conn.Close();
}
return ds;
}
// 显示分类内的相册
public DataSet ShowPhoto(int Category)
{
SqlConnection conn = new SqlConnection(connstr);
string sqlstr = "select * from Photo where CategoryID = @CategoryID";
SqlDataAdapter da = new SqlDataAdapter(sqlstr,conn);
da.SelectCommand.Parameters.Add("@CategoryID",SqlDbType.Int,4).Value = Category;
DataSet ds = new DataSet();
try
{
conn.Open();
da.Fill(ds,"Photo");
}
catch(Exception ex)
{
throw new Exception(ex.Message,ex);
}
finally
{
conn.Close();
}
return ds;
}
// 编辑图片信息
public int EditPhoto(int id, string title, string description)
{
SqlConnection conn = new SqlConnection(connstr);
string sqlstr = "update Photo set Title=@title,Descript=@description where ID=@id";
SqlCommand cmd = new SqlCommand(sqlstr,conn);
cmd.Parameters.Add("@id",SqlDbType.Int,4).Value = id;
cmd.Parameters.Add("@title",SqlDbType.VarChar,50).Value = title;
cmd.Parameters.Add("@description",SqlDbType.VarChar,100).Value = description;
int result = -1;
try
{
conn.Open();
result = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
conn.Close();
}
return result;
}
//分页功能
<asp:DataPager ID="AfterListDataPager" runat="server" PagedControlID="lvPhoto">
<Fields>//CodeGo.net/
<asp:NextPreviousPagerField ButtonType="Image" FirstPageImageUrl="~/images/an_06.gif"
ShowFirstPageButton="true" ShowNextPageButton="False" LastPageImageUrl="~/images/an_12.gif"
NextPageImageUrl="~/images/an_10.gif"
PreviousPageImageUrl="~/images/an_08.gif" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Image" LastPageImageUrl="~/images/an_12.gif"
ShowLastPageButton="true"
ShowPreviousPageButton="False" FirstPageImageUrl="~/images/an_06.gif"
NextPageImageUrl="~/images/an_10.gif"
PreviousPageImageUrl="~/images/an_08.gif" />
</Fields>
</asp:DataPager>