I have a gridview, under a item template I have a table, one of the row of the table look like this
<td bgcolor="White" colspan="2" style="width:100%; background-image:url(bubble1.gif);">
<asp:Panel ID="pnlHistory" runat="server" ScrollBars="Auto">
<asp:Label ID="lblHistory" runat="server" Text='<%# Server.HtmlDecode(Eval("History").ToString()) %>'></asp:Label>
</asp:Panel>
</td>
</tr>
I want to display bubble image as a background, on which my text [i.e. History (coming from database)] will be displayed.
I solved it, I am using Jquery bubble for the same..
This is truly strange that I haven't get any suggestion at stackoverflow for my question, instead I got a missing tag statement...
Anyways, I am posting this answer because I have resolved the issue and if anyone else is looking for the same , then this answer might proof helpful for them.
Related
I want to allow 20k data records in asp.net to filter, sort, paging and edit. Which is the best possible?
Well, as noted, we can't load 20k records at one time - that would be too much data for a use at one time.
So, can you add paging and say display a screen of data in grid/table like view? yes, that's easy.
Can you add sorting to the grid display (say sort up/down) Yes, it will take a wee bit of code, but that can be done quite easy.
But to allow say the user to filter on any column? Hum, that going to take quite a bit of work. So you can certainly acheive the first two goals - quite easy.
but there not any built in filter system + set of controls that will acheive the filtering options for you. I REALLY wish there was. You can consider some 3rd party controls - they are quite expensive, but they do look very nice. So, say this grid from telerick is a great example of what you looking for:
So the above has paging, and sorting, and filters.
demo here:
https://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx
I REALLY don't know why after all these years that the base .net package does not include a grid extender or a listview control that is so feature starved, that everyone every day has to go out and re-invent the world.
But then you have to work to add a data pager And out of the box, the default format for the pager does not look all that great. Once you spend a hour or two, you can get a nice formatted data pager (but it should not be that much work to get a nice look and feel out of the box - it just should not be).
So say here is a listview (I used the wizards - then deleted 99% of the markup, and with this markup:
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ID">
<ItemTemplate>
<tr style="">
<td><asp:label ID="FirstName" runat="server" Text='<%# Eval("FirstName") %>' /></td>
<td><asp:label ID="LastName" runat="server" Text='<%# Eval("LastName") %>' /></td>
<td><asp:label ID="HotelName" runat="server" Text='<%# Eval("HotelName") %>' /></td>
<td><asp:label ID="City" runat="server" Text='<%# Eval("City") %>' /></td>
<td><asp:CheckBox ID="Active" runat="server" Checked='<%# Eval("Active") %>' /></td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">FirstName</th>
<th runat="server">LastName</th>
<th runat="server">HotelName</th>
<th runat="server">City</th>
<th runat="server">Active</th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</LayoutTemplate>
</asp:ListView>
And it looks like this:
So the listview is a nice way to present the data.
However, to get a nice layout, nice filtering, a half decent looking datapager? It takes a truckload of work. The out of the box asp.net controls used to be perhaps the BEST feature of asp.net
That above page was created by me in less time to write this post. It looks not bad - but "not bad" was 5 or 10 years ago.
The new data controls out of the box should be like the first grid - the amounts of efforts to obtain a nice looking grid IMHO is just not all that great right now.
So, I would consider a 3rd party grid control, or you going to have to learn quite a bit of css to get a great looking Excel like display.
It is possible. My beters would be for simple - gridview.
But, for really nice layout - extra options - go with listview - it requires a bit more markup, but has near unlimited flexbility.
There is something strange happening here. I currently have a drop down drpIntervention that has autopostback="true" and up until now I was calling server code, to disable/enable controls depending on what the selected value is. I'm not likeing the flickering with postbacks so I'm trying to wrap the code in UpdatePanel with AsyncPostBack Trigger but strange things are happening:
This is what code looks like for this update panl:
<asp:UpdatePanel ID="UpdatePanel5" runat ="server" UpdateMode ="Conditional">
<ContentTemplate >
<tr>
<td colspan="3" class="questionFont">
<table style="width:100%; border-collapse:collapse ">
<tr>
<td>
<b>a. What is the Problem?</b>
</td>
<td >
<asp:DropDownList ID="drpCrisisType" runat="server" autopostback="true" Enabled ="false" OnSelectedIndexChanged="drpCrisisType_SelectedIndexChanged ">
</asp:DropDownList>
<span runat="server" style="font-size:12px; font-family :'Times New Roman';" ID="Span16"><i>(Description)</i></span>
</td>
</tr>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="drpIntervention" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
and this is code for the button that's supposed to trigger the Event, which is outside the updatePanel
<tr>
<td class="questionFont" style="padding-top: 20px">
<b>4. Did you engage in any?</b>
</td>
<td style="padding-top: 20px">
<asp:DropDownList ID="drpIntervention" runat="server" autopostback="true" OnSelectedIndexChanged="drpIntervention_SelectedIndexChanged ">
</asp:DropDownList>
</td>
</tr>
So this is not my entire code, the <tr> belongs to a table, that has many more above it, this update panel and drop down are just a part of it. What's happening is, I load the page in browser and everything looks good, then I select a value in drpIntervention and the content (other dropdowns, and textboxes that have server code for enabling/disabling) that is wrapped in update panel gets moved above other content in the page. Even stranger, is that the content that gets moved works correctly without doing the postback, however the content is also in its original place and it doesn't work there.
I hope I'm making sense, the content in update panel is literally in 2 places on the page as soon as I select a value from drpIntervention. Mind blown!
I believe the issue had to do with where I was putting the asp:update panel. Since I was putting it inside the table, it was somehow was overriding the formatting and bringing the content within the update panel to top of the the table.
What solved the issue is when I created a table for this questions, and wrapped the entire table with the asp:update panel. This resolved the issues
I'm having problem finding information on selecting data from an Entity Framework entity from within the markup of an ASP.Net Repeater
I have a Repeater like this:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="s_Options">
<HeaderTemplate>
<table>
<tr>
<th>Manager Name</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><% !!!!! MY PROBLEM IS HERE %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
And I have an Entity called Option.
Option has 3 members:OID, Option_Type, and Option_Value
I am trying to populate this repeaters with Option_Values where Option_Type = "This Option" but I am completely lost on how to do this in the item template and I am having trouble wording my question correctly to find answers to it elsewhere.
First of all, if doing this in the markup for the Repeater is not the best way, please let me know.
Additionally, I am looking for any help on how to filter this entity and how the markup looks.
Also, if this is something that has been covered somewhere else, then I apologize, I must be asking the question incorrectly. If you could help me articulate what I'm asking in a more constructive way, please let me know.
If I understand you question correctly, you want -
<ItemTemplate>
<td><%# Eval("Option_Type") %></td>
</ItemTemplate>
Take a look at the bottom of Displaying Data with the DataList and Repeater Controls article.
Use this code and put your table column name in Eval..
<table style="width: 400px">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label ID="LBLtEXT" runat="server" Text='<%#Eval("Your filed name ")%>'></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
I realise there are many posts on the web about this already but I cant seem to find any for my particular problem!
I have a dynamic table that is populated using a repeater.
the code is:
<asp:Repeater ID="rptPending" runat="server">
<HeaderTemplate>
<table id="tblPending" cellpadding="0" cellspacing="0" border="0" class="display">
<thead>
<tr>
<th>Company Name</th>
<th>Telephone</th>
<th>Fax Number</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td runat="server">
<asp:TextBox ID="a" runat="server" TextMode="MultiLine" Rows="1"
onChange="__doPostBack($(this).attr('name'),$(this).parent().attr('id'));"
Text='<%# Eval("_companyName")%>'></asp:TextBox>
</td>
<td runat="server">
<asp:TextBox ID="b" runat="server" TextMode="MultiLine" Rows="1"
onChange="__doPostBack($(this).attr('name'),$(this).parent().attr('id'));"
Text='<%# Eval("_telephone")%>'></asp:TextBox>
</td>
<td runat="server">
<asp:TextBox ID="c" runat="server" TextMode="MultiLine" Rows="1"
onChange="__doPostBack($(this).attr('name'),$(this).parent().attr('id'));"
Text='<%# Eval("_faxNo")%>'></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
Once this table has been populated with data from a datasource, a jquery script iterates through every table cell and edits the id's accordingly. cell_0_0, cell_0_1, cell_0_2 etc.
Now When the text on these text areas change, a postback is initiated, with the __EVENTTARGET being the textarea ID, and the __EVENTARGUMENT being the table cell (parent) ID.
These get sent to the server-side no problem. The issue I am having is GETTING THE TEXT inside the text area...
I have tried adding controls using FindControl("cell_0_0"); Which returns null. Then i found out the FindControl() function IS NOT recursive, so i copied a recursive function off the net... and it Still Fails!
Basically ALL i need to do is GET the value (either innerText or InnerHTML). Ive tried using Control, HtmlControl, HtmlTableRow, and HtmlTextArea.
I just cant seem to get the value. Ive tried recursing throught i a noted earlier, but the controls arent even registered. Im confused.
PLEASE HELP!
Thanks
Alex
Well this is a usually issue, because of the timing of the creations of the controls, and when you create control inside a repeater the timing is even more complex because repeater must first full bind, and then search for the controls.
In my programs to avoid all that I just get the posted value from the Form and I actually not first search to find the control. So just get your posted values from the Request.Form and move on.
Request.Form
All the post data lives on Request.Form, so you can simple get the one you need, or find the one you need. Just a note, to get a value using the Form use the UniqueID, and not the ClientID. Even better get the value from your custom name ids.
I'm trying to add a "panel" with controls dynamicaly. Something like the code below, Clicking "Add" button, displays a "Panel" with the controls(which are within a table), the number of "Education" someone can enter is unlimited. I know how to capture the data, but i can't figure out how to implement/code this,Can anyone please give me some pointers for the same?
Should i be reading about AJAX? I don't know anything about AJAX..
<asp:Panel ID="Panel1" runat="server">
<table>
<tr>
<td><asp:TextBox ID="CollUniv_Name" runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="CollUniv_Location" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="StartDateText" runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="EndDateText" runat="server"></asp:TextBox></td>
</tr>
</table>
Seems like this would more naturally handled by a repeating control. Something along the lines of a ListView control.
There's a fairly full example in the MSDN page I linked to so I won't repeat it here. The two parts you'll want to take a look at a bit more closely are the ItemTemplate which lets you define what normal items look like and the InsertItemTemplate which lets you specify what your insert row will look like. You can also specify if the InsertTemplate appears at the top or bottom. In the code-behind you'll subscribe to the ItemInserting even and handle user input from there.