2014年7月13日 星期日

[RESOLVED] how to set verical direction of repeat for Listview


in my lisview i have set paging but it repeat the item's direction in horizontal manner , but i want it to repeat in vertical , how can i do this 



I set tha  but still it show in horizonatal manner .

i want to set repeat it in vertical  



Hi,


According to your description, you want to repeat the listview in vertical.


Here is a code snippet for you to refer to and the default way is vertical




Group :









Name Description




<%#Eval("LastName")%>
<%#Eval("Address")%>





For more information, please try to refer to the link below:


# ListView inside a Repeater


http://stackoverflow.com/questions/3143759/asp-net-listview-inside-a-repeater


 


If you need more assistance, please feel free to let me know.


Best Regards,


Lisa Zhang



Sir My Listview was showing the itme vertically but i have added the pagging property , after adding this it repeted the column in horizontal manner .



Width="100%">









PostBackUrl='<%#Eval("ItemID","ItemDetails.aspx?ItemID={0}") %>' Width="200px" />











NavigateUrl='<%#Eval("ItemID","ItemDetails.aspx?ItemID={0}") %>'>Buy This



























NavigateUrl='<%#Eval("ItemID","ItemDetails.aspx?ItemID={0}") %>'>Buy This




PostBackUrl='<%#Eval("ItemID","ItemDetails.aspx?ItemID={0}") %>' Width="200px" />








and code behind is 


 protected void showItems()
{
con = new SqlConnection(str);
con.Open();
cmd = new SqlCommand("select * from Items where CategoryID=@a", con);
cmd.Parameters.AddWithValue("@a", id);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
//dlItems.DataSource = ds;
//dlItems.DataBind();
PagedDataSource opjd = new PagedDataSource();
opjd.DataSource = ds.Tables[0].DefaultView;
opjd.AllowPaging = true;
opjd.PageSize = 4;

opjd.CurrentPageIndex = CurrentPage - 1;
cmdPrev.Enabled = !opjd.IsFirstPage;
cmdNext.Enabled = !opjd.IsLastPage;
dlItems.DataSource = opjd;

dlItems.DataBind();
con.Close();
}
public int CurrentPage
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 1; // default page index of 0
else
return (int)o;
}

set
{
this.ViewState["_CurrentPage"] = value;
}
}

protected void cmdNext_Click(object sender, EventArgs e)
{
// Set viewstate variable to the next page
CurrentPage += 1;

// Reload control
showItems();
}
protected void cmdPrev_Click(object sender, EventArgs e)
{
// Set viewstate variable to the previous page
CurrentPage -= 1;

// Reload control
showItems();
}





 





amit_ask




Width="100%">


Hi amit_ask,


RepeatColumns: gets or sets the number of columns to display in the DataList control.


So please try to remove the RepeatColumns property from the DataList. Then the code like this






It works in vertical manner.


Please try it.


If you need more assistance, please let me know.


Best Regards,


Lisa Zhang


 


 


 



沒有留言:

張貼留言