This is my repeater control with data coming from [Patient_Master] table. But Visit_Date is coming from [Patient_Visit] table. How can I show Visit_Date to the same repeater? Is it possible to give two datasources to one repeater? [Patient_Master] and [Patient_Visit] have a relation:
<asp:Repeater ID="repeaterPatientList" runat="server" OnItemDataBound="repeaterPatientList_ItemDataBound" >
<ItemTemplate>
<tr onclick="selectRow(this);">
<td class="csstablelisttd" style="display:none" >
<asp:Label ID="lblPID" runat="server" Text='<%#Eval("PID")%>'></asp:Label>
</td>
<td class="csstablelisttd" >
<%#Eval("Patient_Name")%>
</td>
<td class="csstablelisttd">
<asp:Label ID="lblPatientName" runat="server" Text='<%#Eval("Patient_ID")%>'></asp:Label>
</td>
<td class="csstablelisttd" >
<asp:Label ID="lblSex" runat="server" Text='<%#Eval("Sex")%>'></asp:Label>
</td>
<td class="csstablelisttd">
<asp:Label ID="lblPatientsBirthDate" runat="server" Text='<%#Eval("Patients_Birth_Date")%>'></asp:Label>
</td>
<td class="csstablelisttd">
<asp:Label ID="lblLastVisitDate" runat="server" Text='<%#Eval("Visit_Date")%>'></asp:Label>
</td>
<td class="csstablelisttd">
New
</td>
<td id="tdTodaysVisit" bgcolor="#00cc66" runat="server">
<span class="cssgreen">Today's Visit</span>
</td>
<td class="csstablelisttd">
<%--<asp:HyperLink ID="lnkSchedule" CssClass="csshyperlinkSchedulePatient" runat="server" NavigateUrl='<%# Eval("PID", "~/Create_Order.aspx?ID={0}") %>'>Schedule</asp:HyperLink>--%>
Schedule
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
Why don't you use an outer join between patient_master and patient_visit.
Related
Respected Viewers I need only a specific column does not repeat again and again in Gridview I attache a screenshot in you can see room charges repeat 3 times but I need to this repeat only one time and then its charges and date are shown in simple language it is a heading Please review
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" Width="100%" BorderWidth="0px" BorderStyle="None" OnRowDataBound="GridView1_RowDataBound" ShowFooter="true" OnDataBound="GridView1_DataBound">
<Columns>
<asp:TemplateField HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" FooterStyle-BorderStyle="None" >
<ItemTemplate>
<table style="width:100%;font-size:12px;text-align:left">
<tr>
<td colspan="5">
<table style="width:100%;font-size:16px; font-weight:bold; font-family:Cambria, Cochin, Georgia, Times, Times New Roman, serif;text-align:left;margin-bottom:10px">
<tr><td><u> <asp:Label ID="lblprintheading" runat="server" Text='<%#Eval("Headingname")%>' ></asp:Label></u>
</td></tr>
</table>
</td>
</tr>
<tr>
<td style="width:10%;">
<asp:Label ID="lblservicedate" runat="server" Text='<%#Eval("Date")%>'></asp:Label>
</td> <td style="width:50%;">
<asp:Label ID="lblparticular" runat="server" Text='<%#Eval("Servicename")%>'></asp:Label> (<asp:Label ID="Label22" runat="server" Text='<%#Eval("doctorname")%>'></asp:Label>)
</td>
<td style="width:10%;">
<asp:Label ID="lblrate" runat="server" Text='<%#Eval("Rate")%>'></asp:Label>
</td>
<td style="width:10%;">
<asp:Label ID="lblnos" runat="server" Text='<%#Eval("Qty")%>'></asp:Label>
</td>
<td style="width:20%;">
<asp:Label ID="lblprice" runat="server" Text='<%#Eval("Nettotal")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate >
<table style="width:100%;text-align:center; border:0px none">
<tr>
<td colspan="5" style="text-align:right;padding-right:50px"> ..................................................................................</td>
</tr>
<tr>
<td style="width:10%;">
</td> <td style="width:50%;">
</td>
<td style="width:10%;">
</td>
<td style="width:10%; font-size:18px; font-weight:bold;">
Total:
</td>
<td style="width:20%;">
<asp:Label ID="Label18" runat="server" Text='<%#Eval("Nettotal")%>'></asp:Label>
</td>
</tr>
</table>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
https://i.stack.imgur.com/6Rl6K.png
You can use nested grid view. Which will give you perfect result as you want.
Here is my aspx code. im using a formview and fixed values in which i used an asp.label. but when i run it, formview doesnt show up. i dont have any code behind in which i think i lack? i really appreciate any help. thanks in advance!
<asp:FormView ID="EmployeeFormView" HorizontalAlign="Center"
DataKeyNames="ID"
Gridlines="Both"
RunAt="server"
BackColor="#FFFF66"
BorderColor="#FF8080">
<HeaderStyle backcolor="Navy"
forecolor="#999966"/>
<RowStyle backcolor="White" ForeColor="#CC3300"/>
<EditRowStyle backcolor="#FFFFFF" ForeColor="#FF9966"/>
<ItemTemplate>
<table id="tblcustomerprofile" border="1" cellpadding="1" cellspacing="0">
<tr>
<td style="width:100px">
ID:
</td>
<td style="width:250px">
<asp:Label ID="Label1" runat="server" Text="10999574"></asp:Label>
</td>
<tr>
<td style="width:100px">
Name:
</td>
<td style="width:250px">
<asp:Label ID="Label2" runat="server" Text="Paolo Duhaylungsod"></asp:Label>
</td>
<tr>
<td>
Age:
</td>
<td>
<asp:Label ID="Label12" runat="server" Text="24"></asp:Label>
</td>
<tr>
<td>
Birth Date:
</td>
<td>
<asp:Label ID="Label13" runat="server" Text="06/29/1990"></asp:Label>
</td>
</tr>
<tr>
<td>
Citizenship:
</td>
<td>
<asp:Label ID="Label14" runat="server" Text="Filipino"></asp:Label>
</td>
<tr>
<td>
Status:
</td>
<td>
<asp:Label ID="Label15" runat="server" Text="Single"></asp:Label>
</td>
</tr>
<tr>
<td style="width:100px">
Email Address:
</td>
<td style="width:250px">
<asp:Label ID="Label3" runat="server" Text="paolodexter#yahoo.com"></asp:Label>
</td>
<tr>
<td style="width:100px">
College:
</td>
<td style="width:250px">
<asp:Label ID="Label4" runat="server" Text="De La Salle- College of Saint Benilde"></asp:Label>
</td>
<tr>
<td>
Course:
</td>
<td>
<asp:Label ID="Label5" runat="server" Text="BS- Information Systems"></asp:Label>
</td>
<tr>
<td>
Contact Number:
</td>
<td>
<asp:Label ID="Label6" runat="server" Text="09255666167"></asp:Label>
</td>
</tr>
<tr>
<td>
Address:
</td>
<td colspan="3">
<asp:Label ID="Label7" runat="server" Text="Bf Resort Village, Las Pinas"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<EmptyDataTemplate>
I believe you need to add the default mode property to your formview.
defaultmode="Edit"
without this the formview would be set to show the empty data template.
You could also try to just add all of your code to the empty data template of the formview then it should all show up
The code below get me a comment , puts it in the database and then waits for a page reload to show the comment. How can i make the submited comment to be shown right after it has been posted along with the new ones ? This is the code that does the stuff :
Layout:
<table>
<tr>
<td colspan="2">All Comments</td>
<td>
 
</td>
</tr>
<tr> <td colspan="2"> </td></tr>
<tr>
<td>
<asp:Repeater ID="Repeater1" runat="server" ItemType="SiteStiri.Models.Comments" SelectMethod="GetComments" >
<ItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label id="lblDate" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblComment" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<AlternatingItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label id="Label1" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="Label2" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</td>
</tr>
<td>
<table>
<tr>
<td colspan="2" >Add Your Comment</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblStatus" runat="server" Visible="False"></asp:Label>
</td>
<td>
 
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txtcomment" runat="server" TextMode="MultiLine">
</asp:TextBox>
</td>
<td>
 
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</td>
<td>
 
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
Code Behind:
public void fnSubmitComment()
{
AddComment cmt = new AddComment();
String x = Request.QueryString["newsID"].ToString();
int y = Convert.ToInt32(x);
bool addSucces = cmt.Addcomment( y , txtcomment.Text);
if (addSucces)
{
lblStatus.Text = "Your Comment has been Added Successfully.";
}
else
{
lblStatus.Text = "Your Comment has not been Added.";
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
fnSubmitComment();
}
public IQueryable<Comments> GetComments()
{
var _db = new SiteStiri.Models.CommentsContext();
IQueryable<Comments> query = _db.Comments;
String x = Request.QueryString["newsID"].ToString();
int y = Convert.ToInt32(x);
query = query.Where(p => p.NewsID == y);
return query;
}
I heard i can do that with ajax ? (My knowledge about ajax is 0 currently) Any tips on how i can do this ?
You must wrapper you repeater in an updatepanel,
set UpdateMode="Conditional" and add a trigger on btnSubmit so when click the button the update the repeater with the normal page life cycle
Remember to bind the repeater after that you add the commet in the codebehind and must be present in your page a ScriptManager control
more or less thus
<asp:ScriptManager runat="server" />
<table>
<tr>
<td colspan="2">All Comments</td>
<td> 
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td>
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" ItemType="SiteStiri.Models.Comments" SelectMethod="GetComments">
<ItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label ID="lblDate" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblComment" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<AlternatingItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label ID="Label1" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="Label2" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td colspan="2">Add Your Comment</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblStatus" runat="server" Visible="False"></asp:Label>
</td>
<td> 
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txtcomment" runat="server" TextMode="MultiLine">
</asp:TextBox>
</td>
<td> 
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</td>
<td> 
</td>
</tr>
</table>
</td>
</tr>
</table>
I got a table with 2 nested tables inside that display my two repeaters. My repeaters display Home and office addresses respectively. The problem is that whenever I add a new record in one repeater, the other repeater table's display gets messed up. Like if I add a record in rpt1 , then table for rpt1 moves up and table for rpt2 goes down..ie the headers do not display in one single line . They move up and down when records are added or deleted. WHat I want is these headers to be fixed so if I add new records or delete records, the headings of both repeaters display on the same line...How do I fix this ? Hope its not confusing.
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="50%">
<asp:Panel ID="pnlAddAddress" runat="server">
<asp:Repeater ID="rpt1" OnItemCommand="rpt1_ItemCommand" runat="server" OnItemDataBound="rpt1_OnItemDataBound">
<HeaderTemplate>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" class="linegrey">
</td>
</tr>
<tr class="lgrey">
<td>
Address1
</td>
<td>
City
</td>
<td>
State
</td>
<td>
IsDefault
</td>
<td>
Actions
</td>
</tr>
<tr>
<td colspan="5" class="dots">
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="lnkAddressB" runat="server" Text='<%# Eval("Address1")%>' CommandName="DisplayAddressB" CommandArgument='<%#Eval("AddID") %>' CausesValidation=false></asp:LinkButton>
</td>
<td>
<%# Eval("City")%>
</td>
<td>
<%# Eval("State")%>
</td>
<td>
<%-- Visible='<%# Eval("IsDefault")%>'--%>
<asp:LinkButton ID="lnkDefaultB" Text="Set as Default" CommandName="SetDefaultB" runat="server" CommandArgument='<%# Eval("AddID") + "," + Eval("IsB") %>'
CausesValidation="false" Visible='<%# Eval("IsDefault")%>'></asp:LinkButton>
<asp:Label ID="labelDefaultB" Text="Yes" runat="server" Visible='<%# Eval("IsDefault")%>'></asp:Label>
</td>
<td>
<asp:ImageButton ID="lnkAdd" CommandArgument='<%#Eval("AddID") %>'
CausesValidation="false" CommandName="Edit" runat="server" ImageUrl="~/images/Edit.gif" Width="14" Height="14" ToolTip="Edit"></asp:ImageButton>
<asp:ImageButton ID="lnkDel" Text="Delete" CommandArgument='<%#Eval("AddID") %>'
CausesValidation="false" CommandName="Delete" runat="server" ImageUrl="~/images/Delete.gif" Width="14" Height="14" ToolTip="Delete"></asp:ImageButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
</td>
<td>
<asp:Panel ID="pnlSping" runat="server">
<asp:Repeater ID="rpt12" OnItemCommand="rpt12_ItemCommand" runat="server" OnItemDataBound="rptSpping_OnItemDataBound">
<HeaderTemplate>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" class="linegrey">
</td>
</tr>
<tr class="lgrey">
<td>
Address1
</td>
<td>
City
</td>
<td>
State
</td>
<td>
IsDefault
</td>
<td>
Actions
</td>
</tr>
<tr>
<td colspan="5" class="dots">
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="lnkAddressS" runat="server" Text='<%# Eval("Address1")%>' CommandArgument='<%#Eval("AddID") %>' CommandName="DisplayAddressS" CausesValidation="false"></asp:LinkButton>
</td>
<td>
<%# Eval("City")%>
</td>
<td>
<%# Eval("State")%>
</td>
<td>
<asp:LinkButton ID="lnkDefaultS" Text="Set as Default" CommandName="SetDefaultS" runat="server" Visible=true CommandArgument='<%# Eval("AddID") + "," + Eval("IsS") %>'
CausesValidation="false"></asp:LinkButton>
<asp:Label ID="labelDefaultS" Text="Yes" runat="server" Visible=true></asp:Label>
</td>
<td>
<asp:ImageButton ID="lnkAdd" Text="Edit" CommandArgument='<%#Eval("AddID") %>'
CausesValidation="false" CommandName="Edit" runat="server" ImageUrl="~/images/Edit.gif" Width="14" Height="14" ToolTip="Edit"></asp:ImageButton>
<asp:ImageButton ID="lnkDel" Text="Delete" CommandArgument='<%#Eval("AddID") %>'
CausesValidation="false" CommandName="Delete" runat="server" ImageUrl="~/images/Delete.gif" Width="14" Height="14" ToolTip="Delete"></asp:ImageButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
</td>
</tr>
</table>
Use css attribute valign and set its value to top like this <td width="50%" valign="top">.
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" valign="top">
<asp:Panel ID="pnlAddAddress" runat="server">
......
</asp:Panel>
</td>
<td valign="top">
<asp:Panel ID="pnlSping" runat="server">
......
</asp:Panel>
</td>
</tr>
</table>
For headers look to use the <th> element, this will keep them at the top of the table.
Put the <table> tags you do have outside your repeater controls, make sure the repeater only renders a single row and the same for the header.
Unless you have good reason consider just wrapping the two tables in <div> tags as nested tables really don't work ideally for layout.
I have a Datalist. Following is the structure of the ItemTemplate:
<ItemTemplate>
<div id="driversGrid" runat="server" style="width:3500px;" >
<table cellpadding="0" cellspacing="0" border="0" width="3500px">
<tr>
<td id="Td1" runat="server" style="visibility:hidden;">
<asp:Label ID="lblID" runat="server" BackColor="White" Font-Bold="true" Text='<%# Eval("ID") %>' /><br />
</td>
<td id="title" style="width:90px;text-align:center;">
<asp:Label ID="lblTitle" runat="server" BackColor="White" Font-Bold="true" Text='<%# Eval("Name") %>' /><br />
</td>
<td id="am0900" runat="server" style="width:90px;"> </td>
<td id="am0915" runat="server" style="width:90px;"> </td>
<td id="am0930" runat="server" style="width:90px;"> </td>
<td id="am0945" runat="server" style="width:90px;"> </td>
<td id="am1000" runat="server" style="width:90px;"> </td>
<td id="am1015" runat="server" style="width:90px;"> </td>
<td id="am1030" runat="server" style="width:90px;"> </td>
<td id="am1045" runat="server" style="width:90px;"> </td>
<td id="am1100" runat="server" style="width:90px;"> </td>
</tr>
</table>
</div>
</ItemTemplate>
Now, at the itemdatabound event, I fetch multiple time (data) from the database in form 10:25 AM.
I manipulate each data and convert it to am1030 (similar to one of the td ID in itemTemplate). Now I want to check each td in ItemTemplate and compare the lblID (i.e. the staff ID) to the ID in my variable and then compare the tdID to the manipulated data. If they match change the background color of the td.
In short, I want to check that if the lblID is 3 then get the td with ID am1030 and change the background color.
Needs to be done in C#.net.
Use a foreach loop to iterate through the e.Item.Controls collection, like this -
foreach (Control c in e.Item.Controls)
{
//if c is HtmlCell, then check the ID and change the color.
}