asp.net formview generates table at fixed width 259px - asp.net

Dynamically generated table in FromView is causing problem in my JQuery Mobile page. I have narrowed it down to the table that is generated is fixed at a width of 259px with an ID of table#ctl00_ContentPlaceHolder1_FormView1
I'm not sure how to change this to dynamic in asp.net FromView:
<asp:FormView ID="FormView1" runat="server" DataKeyNames="FDID" DataSourceID="AccessDataSource1" DefaultMode="Insert">
<EditItemTemplate>
<ul data-role="listview" id="ul-edit-picks" data-divider-theme="a" data-inset="true" data-scroll="true">
<li data-role="list-divider">
<h2 id="itemTitle">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("FDID")%>' Font-Bold="True" Font-Size="Medium"></asp:Label>
: Selections</h2>
</li>
...

I know this is a very old post - you can just not generate the formview inside a table
asp:FormView ID="MyFormView" **RenderOuterTable="false"

ok not sure why the <FormView> defaulted to 259px but the fix was to add Width="100%" to the control, I have never had this issue in the past, but I guess I just liked the default look.

Related

Display Nested ListViews (Menus to Submenus) with AccessDataSource

Good Days,
By using ASP.NET and AccessDataSource, I need to display a listview inside a parent listview to be able to have menus and their submenus. Current state of my code is:
<asp:AccessDataSource ID="adsMenus" runat="server" DataFile="~/App_Data/menus.accdb" SelectCommand="SELECT MenuID, Menu FROM Menus" />
<asp:ListView ID="lvwMenus" runat="server" DataSourceID="adsMenus" DataKeyNames="MenuID">
<ItemTemplate>
<h2><%#Eval("Menu")%></h2>
<asp:AccessDataSource ID="adsSubmenus" runat="server" DataFile="~/App_Data/menus.accdb" SelectCommand="SELECT Submenu FROM Submenus WHERE MenuID = <%#Eval('MenuID')%>" />
<asp:ListView ID="lvwSubmenus" runat="server" DataSourceID="adsSubmenus">
<ItemTemplate>
<h3><%#Eval("Submenu")%></h3>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
When I debug and run the page, it gives a syntax error. I am in the phase of learning ASP.NET with C# and I believe this should be an easy fix but somehow I couldn't find a simple solution after reading several blogs and posts.
Thank you for your help and time!
Attribute that has a value formed from literals and evaluated fields should be, as a rule, constructued wholly in the <%# %>:
SelectCommand='<%# string.Format("SELECT Submenu FROM Submenus WHERE MenuID = {0}", Eval("MenuID")) %>'

use ajax into repeater to update data

I've a repeater ASP.NET control that contain an image slider that display 3 images every 10 sec by random from DB.I used a UpdatePanel ASP.NET control to reload this repeater .every things is OK, but I've a problem, when passed 10 seconds page is refresh! and i don't want to refresh page.How to fix this problem?
this is ASP.NET code:
<div id="middleSliderArea">
<div class="pikachoose">
<ul id="pikame">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<li>
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<asp:Timer runat="server" ID="Timer1" Interval="10000" OnTick="Timer1_Tick"></asp:Timer>
<a href='<%#"MoreInfo.aspx?id="+Eval("ID") %>'>
<img runat="server" src='<%#Eval("Image") %>' /></a><span><%#Eval("Brief") %></span>
</ContentTemplate>
</asp:UpdatePanel>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</div>
and you can see this effect here after 10 seconds.
You need to get all images ID's from DB to client Side (you use JSON object) at the beginning , after page load.
Then use "setInterval javascript method" and call another Javascript Method (for examle changeImage() ).
In changeImage() method you select img elements in the repeater than you can change the values and images. I know the explanation is not enought for you right now , if you need more I can help you ..

HTML: Keep checkbox and associated text together while its container is resized

I have an ASP.Net page which renders checkboxes as below
But when I re-size the screen, the controls are crammed together and the checkboxes & their associated text move into different lines and it wouldn't make much sense.
I would like to know if there is a way to keep the checkboxes together.
Heres the Code:
<asp:Repeater ID="rpFiles" runat="server" DataSource='<%# Eval("Files") %>' OnPreRender="rpFiles_PreRender" >
<ItemTemplate>
<asp:PlaceHolder ID="phFile" runat="server">
<asp:CheckBox ID="cbVisibility" AutoPostBack="false" runat="server" Text='<%# string.Format("{0} ({1})", Eval("FileName"), Eval("FileType").ToString().ToUpper()) %>' Checked='<%# !((bool)DataBinder.Eval(Container.DataItem, "IsHidden")) %>' />
<asp:HiddenField ID="hfFileID" Value='<%# Eval("FileID") %>' runat="server" />
</asp:PlaceHolder>
</ItemTemplate>
</asp:Repeater>
Thanks for your input guys. Tried working on your lines. width and min-width were not working but the idea of div was important, +1 for that.
I have used this instead
<asp:PlaceHolder ID="phFile" runat="server">
<div style="display:inline-block; padding-right:15px"><asp:CheckBox ID=...
and that fixes it.
If it's a CheckBoxList then the width must be constrained somehow? Set a fixed width to prevent the collapse.
<div style="min-width:600px;">
<!-- check boxes ->
</div>
Note that this width is just arbitrary; play around with it...
UPDATE: now that I see your markup, just set a width on the repeater.
Suppose you have code
<!--CheckboxCatering Order(PDF)--!>
Then update your code like
<div style="width:300px;"><!--checkboxCatering Order(PDF)--!></div>
It will solve your problem

Passing Value Through Link Button in ASP.NET

Conditions :
I have two tables,
category(id_kat,name_kat)
book(id_book,id_kat,name_book)
id_kat has a child and parent relations.
I'm a little bit confused using ASP.NET, especially when passing value between pages.
Now, i'm showing the category's datas with
<asp:listview id="listview1" runat="server" datakeynames"id_kat" datasourceID="sdskat">
//FYI sdskat is datasource for category table
<itemtemplate>
<li>
<asp:linkbutton id="linking" runat="server" ><%# Eval("name_kat") %></asp:linkbutton>
</li>
</itemtemplate>
</asp:listview>
The problem is, i wanted to pass "id_kat" value when i click the hyperlink. (but redirected to self page).
I want it as a query string (or another way if able).
Thanks a lot.
If you're linking to the same page with different query string parameters, you only need to include ? and after.
<%# Eval("name_kat") %>
You could use <asp:hyperlink id="linking" runat="server" ><%# Eval("name_kat") %></asp:hyperlink> instead. You can then add your url in the navigateURL attribute and append your id_kat on there.
Something like this should work:
<asp:hyperlink id="linking" runat="server" navigateURL="~/page.aspx?id_kat=<%# Eval('id_kat') %>" ><%# Eval("name_kat") %></asp:hyperlink>
the <asp:hyperlink> tag is essentially the tag but using a server side control.
If you have to use a linkbutton then in your code behind you can append the id_kat to the querystring and then response.redirect(url) to the new page.
Why not use a regular anchor?
<a href='foo.aspx?id=<%# Eval("id_kat") %>'><%# Eval("name_kat") %></a>

ajax collaps panel not working in my application?

i am going to implement the collapsiblepane in my application but it is not getting any thing just two link buttons
this is my code
CollapsiblePanelExtender ID="CollapsiblePanelExtender1"
AutoCollapse ="False" AutoExpand ="false" ScrollContents ="true" TargetControlID ="mypanel"
Collapsed ="true" CollapsedSize ="0" ExpandedSize ="300"
ExpandControlID ="mylink" CollapseControlID ="mylink2"
CollapsedText ="Show Details..." ExpandedText ="Hide Details..." runat="server">
</cc1:CollapsiblePanelExtender>
<asp:Panel ID ="mypanel" runat ="Server" Visible ="False" >
<asp:TextBox ID="txt" runat ="server" ></asp:TextBox><br />
<asp:Button ID="btn" runat ="Server" Text ="Click" />
</asp:Panel>
<asp:LinkButton ID="mylink" runat ="Server" Text ="Mydetaails" OnClick="mylink_Click" ></asp:LinkButton>
<asp:LinkButton ID="mylink2" runat ="Server" Text ="HideMydetails" OnClick="mylink2_Click" ></asp:LinkButton>
I'm not sure but can see at least 2 problems:
You server tag of CollapsiblePanelExtender must be closed, so you have:
runat="server">
but it must be:
runat="server"/>
Did you recreate CSS classes? CollapsiblePanelExtender works by manipulating styles, so these styles must be present. Also look at note from ( http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CollapsiblePanel/CollapsiblePanel.aspx ) "Note: CollapsiblePanel assumes that the standard CSS box model is being used ... so please use the !DOCTYPE declaration (as found at the top of this page and enabled by default for new ASP.NET pages) to specify that the page should be rendered in IE's standards-compliant mode."

Resources