I am trying create a table and add this table into tablecell (table inside table in short)
It seems to be working with pure html and Javascript but it does not seem to work with asp.net table. I have tried to add other controls to the particular cell, like adding labels, htmldiv, textboxes and they all work fine except table.
Does anyone how to to achieve this by any chance?
If i understand you right here is an example:
<asp:Table runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Table runat="server">
</asp:Table>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
Related
I am trying to display a table on the button click,right below the button,but it is getting display on the top of the page(Above the navbar).
This is what I did:
Response.Write("<table border='1' cellpadding='2' WIDTH='20%' height='10px' style=\"margin-bottom:10px\">");
what should be done to align the table below the button?please help
you should place a control and that add it into that control.
You can also take the help of html generic controls to add html control in the controls.
<asp:panel id="panel1" runat="server">
</panle>
and in code behind
panel1.InnerHtml="";
You should not be using Response.write. Either:
1) Use some JavaScript and HTML to show/hide the table.
2) Use server side control for example
ASPX page
<asp:panel runat="server" id="foo" visible="false">
<table border='1' cellpadding='2' WIDTH='20%' height='10px' style=\"margin-bottom:10px\>
....
<asp:panel>
Code
foo.Visible = true;
See Show/Hide panels in ASP.net C# after submitting form
I'm working on aspx pages and i have asp.net Menu and CSS assigned to it.
But when I run the application the CSS class names get changed and its dynamically created as we see in controls inside "ContentPlaceHolder".
The code is
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal">
<DynamicItemTemplate>
<%# Eval("Text") %>
</DynamicItemTemplate>
<Items>
.
.
.
</Items>
</asp:Menu>
please check this Image what i get when i run this..
I checked my application to know whether the Menu control is placed inside content placeholder or anything. But its not.
Do anyone know how to solve this issue.
class="menu ct100..." means that this element has two classes 1:menu and 2:ct100...
and nothing is wrong with it!the ct100... is generated by asp.net and if it is different any time you run the page it's up to asp.net component and if you dont like that try not to use this built in component, that i think you should do it.
by the way the only thing is changing when using master pages is client side id, that you can avoid this from happening by code below
<asp:TextBox ID="myId" runat="server" ClientIDMode="Static"></asp:TextBox>
set ClientIDMode to Static
I developed a gridview by following this tutorial but i want to change it's css, can someone point me to right direction please,
Here's a little bit of markup
<asp:GridView ID="GridView1"
runat="server"
DataKeyNames="CustomerID" AutoGenerateColumns="false"
OnRowDataBound="gv_RowDataBound" Width="80%"
AllowPaging="True" PageSize="20" cssClass="myclass" />
I added a css class but not sure what will go in class so that I make my gridview attractive,
Please check below codeproject link. This may help you.
Add some style to your datagrids
You can use the this : http://msdn.microsoft.com/en-us/library/aa479342.aspx . Skin is easy to maintain and change
Facts:
I'm working under Visual Studio .NET 2008
I'm using Cufon-yui.js as a font replacement tool.
The link is inside of a Table <td> (as it handle much more info)
The command I use is:
<asp:HyperLink ID="thisistheID" runat="server" NavigateUrl="#">
<h3 style="width:250px;">Title of the Link</h3>
</asp:HyperLink>
In Firefox and IE, I'd like to mouse over the text and have the link there, solely. If I mouse over the whole cell (of the table) the link is available and appears there even tho I don't have letters there.
How can I have this link to work just where the letters are?
I hope I asked this question the appropriate way.
What happens if you turn it inside-out?
<h3 style="width:250px;">
<asp:HyperLink ID="thisistheID" runat="server" NavigateUrl="#">
Title of the Link
</asp:HyperLink>
</h3>
I think the problem is that you are making the h3 tag a link. Two ways to fix it if this is the case....
a. Style the asp:HyperLink and don't specify the width (no need for h3 tag unless you are doing some javascript stuff for it).
<asp:HyperLink ID="HyperLink1" runat="server"
Font-Bold="True"
Font-Size="Large"
text="Title of the Link"
NavigateUrl="default.aspx" ></asp:HyperLink>
b. Use plain old html mark up inside the h3 tag if you don't need to access the control server side:
<h3 style="font-size: larger">
Title of the Link
</h3>
I am attempting what I think is a rather simple databinding scenario with Linq To SQL.
I have a table of FacultyMembers, whose schema looks something like this:
FacultyMemberID - int PK
Name - nvarchar
UniversityID - int FK to University table
and so forth. There are various other string properties.
I generate LTS DataClasses. I drop a LinqDataSource and a GridView on a page, enable update and delete for both, and I'm on my merry way. No code, and I'm able to update my string properties. A little manipulation with a DropDownList on the UniversityID and I'm able to update that one-to-many relationship, too. Yay.
Now, lets say I throw in a many-to-many mapping table. Let's say DivisionMemberships, which maps FacultyMembers to Divisions. DivisionMembership uses the simple and obvious schema:
FacultyMemberID - int PK, FK to FacultyMembers table
DivisionID - int PK, FK to Divisions table
Now, when I take a row of my GridView into EditMode, I run into a problem because I don't know how to update the many-to-many relationship. I mucked around with a few alternatives, and right now I'm trying to get a ListView to work in there. I'm doing something like this:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True" PageSize="25" DataKeyNames="FacultyMemberID" >
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:TemplateField HeaderText="University" SortExpression="UniversityID">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("University.Name") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="LinqDataSourceUniversities" DataTextField="Name"
DataValueField="UniversityID" SelectedValue='<%# Bind("UniversityID") %>'>
</asp:DropDownList>
<asp:LinqDataSource ID="LinqDataSourceUniversities" runat="server"
ContextTypeName="NYDERHE.NYDERHEDataClassesDataContext"
Select="new (UniversityID, Name)" TableName="Universities">
</asp:LinqDataSource>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Division">
<EditItemTemplate>
<asp:ListView ID="ListView1" runat="server"
InsertItemPosition="LastItem" DataSource='<%# Eval("DivisionMemberships") %>'><ItemTemplate>
<li style="">FacultyMemberID:
<asp:Label ID="FacultyMemberIDLabel" runat="server"
Text='<%# Eval("FacultyMemberID") %>' />
<br />
DivisionID:
<asp:Label ID="DivisionIDLabel" runat="server"
Text='<%# Eval("DivisionID") %>' />
<br />
Division:
<asp:Label ID="DivisionLabel" runat="server" Text='<%# Eval("Division") %>' />
<br />
FacultyMember:
<asp:Label ID="FacultyMemberLabel" runat="server"
Text='<%# Eval("FacultyMember") %>' />
<br />
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete"
Text="Delete" />
</li>
</ItemTemplate>
</asp:ListView>
</EditItemTemplate>
and so forth. Some of the chatter above is removed, but ListView is pretty verbose as-is, so I don't want to overload the page.
Things to note here:
For my University association, I use a new LinqDataSource and query for items WHERE the UniversityID matches, then bind the new UniversityID (DDL value) to the FacultyMember, whereas for the DivisionMemberships, I bind directly to the property (as described here)
I use DataBinder.Bind() for UniversityID, whereas I use DataBinder.Eval() for DivisionMemberships.
If I switch to Bind() for DivisionMemberships, I get a NotSerializableException for EntitySet. If I stick with Eval(), I have to write the OnDelete and OnInsert methods for the ListView myself, and I don't want to Delete or Insert the DivisionMemberships until the entire FacultyMember row exits EditMode. I'd probably create a DataContext and stick it in the session for this, because I don't have another way to mark the DivisionMemberships for updates.
I would think that this scenario would be pretty easy to enable out of the box, but I'm lost. Any advice on where to go from here? Specifically, should I wrestle with Bind() and try to make EntitySet serializable, should I bite the bullet and write the somewhat hackish code described above for storing a DataContext in session until the OnRowUpdating event fires, or am I going the wrong way completely?
You're right, it is long, but kudos on including some code, JIC.
It does seem apparent that you're not going to be able to do this with ordinary DataBinding. I'm not too keen on storing this in session, but I do understand that you don't want a postback.
What you might want to do is set up an Ajax call so that you can stick your new record (or your record change) into the DataContext. When the form is submitted, you can call SubmitChanges on the DataContext.
Seems to me Josh that trying to manage your many-to-many relationship from within the Faculty Member grid is not the right approach.In fact, I can't really visualise how this would work inside a grid, I am not surprised that you are lost :)
Better to use a 'detail' page where the context is = to a single Faculty member and provide a 'double list' interface for division membership maintenence. This would consist of 2 lists.
The righthand list shows all the divisions to which the faculty member is already a member(DivisionMembership rows where FacultymemberId = the context id) , the left hand list would show all the remaining Divisions. You could then provide '>>' and '<<' buttons in between the lists to add/remove the Faculty member from the divisions (Inserting/deleting DivisionMemberships rows)
Michael