Javascript 使用asp.net在网页上显示多个图像
我正在从数据库中获取图像并将在网页上显示图像,如果图像较多,我想显示“显示更多图像”按钮,如果用户单击ASP.Net中的“显示更多”按钮,我还想在同一网页上自动显示更多图像。您可以使用转发器:Javascript 使用asp.net在网页上显示多个图像,javascript,css,asp.net,Javascript,Css,Asp.net,我正在从数据库中获取图像并将在网页上显示图像,如果图像较多,我想显示“显示更多图像”按钮,如果用户单击ASP.Net中的“显示更多”按钮,我还想在同一网页上自动显示更多图像。您可以使用转发器: <asp:Repeater ID="rptStudentDetails" runat="server"> <HeaderTemplate> <table border="1" cellpadding="1"> <tr
<asp:Repeater ID="rptStudentDetails" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="1">
<tr style="background-color: #fa7b16; color: #FFF; height: 35px;" align="center">
<th>
Student Name
</th>
<th>
Class
</th>
<th>
Age
</th>
<th>
Gender
</th>
<th>
Address
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: white;" align="center">
<td>
<%#Eval("StudentName") %>
</td>
<td>
<%#Eval("Class") %>
</td>
<td>
<%#Eval("Age") %>
</td>
<td>
<%#Eval("Gender") %>
</td>
<td>
<%#Eval("Address") %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:Button ID="btnLoadMore" runat="server" Text="Load More Data" OnClick="btnLoadMore_Click" />
有关详细信息,请参阅下面的Url:
请展示你的代码。不要期待别人的一切,至少要展示你所做的努力
protected void btnLoadMore_Click(object sender, EventArgs e)
{
//On every click of this button it will add 2 to the ViewState["num"] whose value was set to 2 initially on page load. So numval is 4 now.
int numVal = Convert.ToInt32(ViewState["num"]) + 2;
//Now pass numVal whose value is 4 to the BindRepeater function to get 4 rows.
BindRepeater(numVal);
//Set ViewState["num"] is equal to the numVal i.e. 4 so that when we again click this button it will be 4 + 2= 6 and so on.
ViewState["num"] = numVal;
}
private void BindRepeater(int numOfRows)
{
DataTable dt = new DataTable();
SqlCommand cmd = null;
SqlDataAdapter adp = null;
try
{
//get number rows in table by calling the rowCount function i created.
int rCount = rowCount();
// hide the "Load More Data button" if the number of request rows becomes greater than the rows in table
if (numOfRows > rCount)
{
btnLoadMore.Visible = false;
}
cmd = new SqlCommand("GetStudentDetails_SP", con);
//Passs numOfRows variable value to stored procedure to get desired number of rows
cmd.Parameters.AddWithValue("@topVal", numOfRows);
cmd.CommandType = CommandType.StoredProcedure;
adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
rptStudentDetails.DataSource = dt;
rptStudentDetails.DataBind();
}
}
}