I have a gridview and i have set a fixed header but the width of the columns in the gridview does not align with the column of the header.
<div style="width:1000px;border:1px solid #084B8A;color:#ffffff;font-weight:bold;">
<table style="color:#3090C7;">
<tr>
<td style ="width:120px;">Item_ID</td>
<td style ="width:200px;">Category</td>
<td style ="width:300px;">ItemName</td>
<td style ="width:120px;">Pack_Size</td>
<td style ="width:200px;">CostPrice</td>
<td style ="width:200px;">SalesPrice</td>
<td style ="width:150px;">Stock</td>
<td style ="width:150px;">Reorder</td>
<td style ="width:200px;">Barcode</td>
<td style ="width:200px;">Barcode2</td>
<td style ="width:200px;">Barcode3</td>
<td style ="width:200px;">Barcode4</td>
<td style ="width:200px;">Item_Discontinued</td>
</tr>
</table>
</div>
<div style ="height:300px; width:1000px; overflow:auto;" >
<asp:GridView ID="GrdItemList" runat="server" AutoGenerateColumns="false"
ShowHeader = "false" Width ="1000px" >
<AlternatingRowStyle BackColor="#BFE4FF" />
<Columns>
<asp:BoundField ItemStyle-Width = "120px" DataField="Item_ID" HeaderText="Item_ID"
/>
<asp:BoundField ItemStyle-Width = "200px" DataField="Category" HeaderText="Category"
/>
<asp:BoundField ItemStyle-Width = "300px" DataField="ItemName" HeaderText="ItemName"
/>
<asp:BoundField ItemStyle-Width = "120px" DataField="Pack_Size"
HeaderText="Pack_Size" />
<asp:BoundField ItemStyle-Width = "200px" DataField="CostPrice"
HeaderText="CostPrice" />
<asp:BoundField ItemStyle-Width = "200px" DataField="SalesPrice"
HeaderText="SalesPrice" />
<asp:BoundField ItemStyle-Width = "150px" DataField="Stock" HeaderText="Stock" />
<asp:BoundField ItemStyle-Width = "150px" DataField="Reorder" HeaderText="Reorder"
/>
<asp:BoundField ItemStyle-Width = "200px" DataField="Barcode" HeaderText="Barcode"
/>
<asp:BoundField ItemStyle-Width = "200px" DataField="Barcode2"
HeaderText="Barcode2" />
<asp:BoundField ItemStyle-Width = "200px" DataField="Barcode3"
HeaderText="Barcode3" />
<asp:BoundField ItemStyle-Width = "200px" DataField="Barcode4"
HeaderText="Barcode4" />
<asp:BoundField ItemStyle-Width = "200px" DataField="Item_Discontinued"
HeaderText="Item_Discontinued" />
</Columns>
</asp:GridView>
</div>
I want the output to be that if the header of say 'ItemID' is 50px, the column in the gridview holding the 'ItemID' also should be exact 50px and not overlapping.
Related
I have a checkboxlist in a formview itemtemplate. In edit mode I want to select the items that are in a datatable. I cannot find how to do this. I am using VB.NET.
ASP.NET code:
<asp:FormView ID="rdf" runat="server" Width="100%" DataSourceID="sqldatasource1" OnItemCreated="rdf_ModeChanging" rendermode="Lightweight" onrowupdating="updatebutton_click" DataKeyNames="applicationid" >
<ItemTemplate>
<fieldset style="width: 97%">
<div>
<br />
<asp:Label runat="server" ID="FiscalOrgNameLabel2" Text="Fiscal Organization: " Style="font-weight: bold; font-size: 15px;"></asp:Label><asp:Label Text='<%# Eval("FiscalOrgName") %>' runat="server" ID="FiscalOrgNameLabel1" />
</div>
<br />
<asp:panel id="cntyPanel" runat="server" >
<asp:label ID="countyLabel" runat="server" style="font-weight: bold; font-size: 15px; "
text="County(s): (if applicable)">
<asp:DataList ID="dlCounty" runat="server" DataSourceID="sqlCounty" Style="font-weight: normal;" >
<ItemTemplate>
<li>
<%# Eval("county") %>
</li>
</ItemTemplate>
</asp:DataList>
</asp:label>
</asp:panel>
<asp:panel id="IHEPanel" runat="server" >
<asp:label ID="instLabel" runat="server" style="font-weight:bold; font-size: 15px; "
text="Institution(s): (if applicable)">
<asp:datalist ID="dlIHE" runat="server" DataSourceID="sqlIHE" style="font-weight:normal;">
<ItemTemplate>
<li >
<%# Eval("Institute") %>
</li>
</ItemTemplate>
</asp:datalist>
</asp:label>
</asp:panel>
<asp:SqlDataSource ID="sqlCounty" runat="server" ConnectionString='<%$ ConnectionStrings:COSIGrantsDB %>' SelectCommand="SELECT dbo.County.County as county, dbo.Application_County.ApplicationId, dbo.Application_County.CountyId
FROM dbo.County INNER JOIN
dbo.Application_County ON dbo.County.CountyID = dbo.Application_County.CountyId where applicationid=#appid">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="appid" Name="appid"></asp:QueryStringParameter>
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource runat="server" ID="sqlGetBehalf" ConnectionString='<%$ ConnectionStrings:COSIGrantsDB %>' SelectCommand="getBehalf" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="appid" Name="appid" Type="Int32"></asp:QueryStringParameter>
<asp:QueryStringParameter QueryStringField="apptypeid" Name="apptypeid" Type="Int32"></asp:QueryStringParameter>
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource runat="server" ID="sqlIHE" ConnectionString='<%$ ConnectionStrings:COSIGrantsDB %>' selectcommand="SELECT dbo.Application_IHE.ApplicationID, dbo.IHE.Institute
FROM dbo.Application_IHE INNER JOIN
dbo.IHE ON dbo.Application_IHE.IHE = dbo.IHE.iheID where applicationid = #appid" SelectCommandType="text">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="appid" Name="appid" Type="Int32"></asp:QueryStringParameter>
</SelectParameters>
</asp:SqlDataSource>
<div>
<div class="rdfCommandButtons">
<hr class="rdfHr" />
<telerik:RadButton runat="server" ButtonType="SkinnedButton" RenderMode="Lightweight" CommandName="Edit" Text="Edit" ID="EditButton" ToolTip="Edit" CausesValidation="False" />
</div>
</fieldset>
</ItemTemplate>
<EditItemTemplate>
<fieldset style="width: 97%"> <br />
<asp:Label ID="editApptypeId" runat="server" Text='<%# Eval("applicationtype") %>'></asp:Label>
<div style="display:table; width:100%">
<div style="display:table-row;">
<div style="display:table-cell;">
Fiscal Organizaton:
</div>
<div class="cell textcell">
<asp:TextBox ID="fiscalOrg" runat="server" Text='<%# Bind("FiscalOrgName") %>'></asp:TextBox>
</div>
</div>
</div>
<div id="cntyPanel" visible="true" runat="server">
<div runat="server" style="font-weight: bold; font-size: 15px;">
County(s):
<asp:CheckBoxList ID="ckCounty" runat="server" RepeatColumns="8" DataTextField="county" DataValueField="countyid" ></asp:CheckBoxList>
<br />
</div>
<div id="IHEPanel" visible="false" runat="server">
<div runat="server" style="font-weight:bold; font-size: 15px;">
Institution(s):
<asp:datalist ID="dlIHE" runat="server" DataSourceID="sqlIHE" style="font-weight:normal;">
<ItemTemplate>
<li >
<%# Eval("Institute") %>
</li>
</ItemTemplate>
</asp:datalist>
</div>
</div>
<asp:SqlDataSource runat="server" ID="sqlGetBehalf" ConnectionString='<%$ ConnectionStrings:COSIGrantsDB %>' SelectCommand="getBehalf" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="appid" Name="appid" Type="Int32"></asp:QueryStringParameter>
<asp:QueryStringParameter QueryStringField="apptypeid" Name="apptypeid" Type="Int32"></asp:QueryStringParameter>
</SelectParameters>
</asp:SqlDataSource>
</div>
<asp:SqlDataSource runat="server" ID="sqlIHE" ConnectionString='<%$ ConnectionStrings:COSIGrantsDB %>' selectcommand="SELECT dbo.Application_IHE.ApplicationID, dbo.IHE.Institute
FROM dbo.Application_IHE INNER JOIN
dbo.IHE ON dbo.Application_IHE.IHE = dbo.IHE.iheID where applicationid = #appid" SelectCommandType="text">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="appid" Name="appid" Type="Int32"></asp:QueryStringParameter>
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
<EmptyDataTemplate>
<div>
<div class="rdfEmpty">There are no items to be displayed.</div>
</div>
</EmptyDataTemplate>
</asp:FormView>
VB.NET:
Protected Sub rdf_itemcommand(sender As Object, e As FormViewCommandEventArgs) Handles rdf.ItemCommand
Dim county As CheckBoxList = DirectCast(rdf.FindControl("ckCounty"), CheckBoxList)
conn.Open()
Using cmd As New SqlCommand("select * from application_County where applicationid =" + Request.QueryString("appid"), conn)
Using rdr = cmd.ExecuteReader()
If rdr.HasRows Then
Do While rdr.Read
For Each item As ListItem In county.Items
If item.Value = rdr.GetValue(2) Then
item.Selected = True
End If
Next
Loop
End If
End Using
End Using
End Sub
I get an error on county:
Object reference not set to an instance of an object.
When I debug it, county checkboxlist is empty. Why can't I find the checkboxlist in the edititemtemplate?
Without seeing the code you currently have it is a little difficult to guide you, however if you post the code I would be more than happy to help.
You are going to need a for loop in the code behind the goes through and sets everything to checked.
For each checkBoxItem as listItem in [NameOfCheckBox].Items
checkBoxItem.selected = true
next
This is my Radgrid and I am trying to call contact type, projectid and ContactName in the .vb code. Please help me obtain it.
As the entire design is under template I was not sure how we access the RadDropDownList, texboxes and ETC.
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" PageSize="50" Width="99%" OnItemUpdated="RadGrid1_ItemUpdated" OnItemInserted="RadGrid1_ItemInserted" OnItemDeleted="RadGrid1_ItemDeleted"
AutoGenerateColumns="False" AutoGenerateEditColumn="True" AutoGenerateDeleteColumn="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" OnDataBound="RadGrid1_DataBound">
<MasterTableView DataSourceID="SqlDataSource1" CommandItemDisplay="Top" DataKeyNames="ProjectID,ContactType">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Wrap="true" />
<EditItemStyle HorizontalAlign="Left" />
<Columns>
<telerik:GridBoundColumn DataField="ProjectID" UniqueName="ProjectID" FilterControlAltText="Filter ProjectID column" HeaderText="ProjectID" ReadOnly="True" SortExpression="ProjectID" Display="false">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="ContactType" HeaderText="Contact Type">
<ItemTemplate>
<asp:Label Text='<%# Eval("ContactTypeDesc")%>' runat="server" />
</ItemTemplate>
<InsertItemTemplate>
<telerik:RadDropDownList ID="ddlContactType" runat="server" DropDownWidth="100%" SelectedValue='<%# Bind("ContactType") %>' DataSourceID="SqlDataSource2" DataValueField="ContactTypeID" DataTextField="ContactTypeDesc" />
<br />
<asp:RequiredFieldValidator Display="Dynamic" ErrorMessage="* Required Field" ForeColor="Red" ControlToValidate="ddlContactType" runat="server" />
</InsertItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ContactName" HeaderText="Contact Name" SortExpression="ContactName" UniqueName="ContactName" FilterControlAltText="Filter ContactName column">
<ItemTemplate>
<asp:Label Text='<%# Eval("ContactName")%>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox ID="txtName" runat="server" Text='<%# Bind("ContactName")%>' MaxLength="100"></telerik:RadTextBox><br />
<asp:RequiredFieldValidator Display="Dynamic" ErrorMessage="* Required Field" ForeColor="Red" ControlToValidate="txtName" runat="server" />
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ContactEmailAddress" HeaderText="Contact Email">
<ItemTemplate>
<asp:Label Text='<%# Eval("ContactEmailAddress")%>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox ID="txtEmail" runat="server" Text='<%# Bind("ContactEmailAddress")%>' MaxLength="100"></telerik:RadTextBox><br />
<asp:RegularExpressionValidator ID="emailValidator" runat="server" Display="Dynamic" ForeColor="Red"
ErrorMessage="Please, enter valid e-mail address." ValidationExpression="^[\w\.\-]+#[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"
ControlToValidate="txtEmail">
</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator Display="Dynamic" ErrorMessage="* Required Field" ForeColor="Red" ControlToValidate="txtEmail" runat="server" />
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ContactInternationalNumber" HeaderText="International Code">
<ItemTemplate>
<asp:Label Text='<%# String.Format("+{0}", Eval("ContactInternationalNumber"))%>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDropDownList ID="ddlCountryCodes" runat="server" DropDownHeight="150px" DropDownWidth="100%" SelectedValue='<%# Bind("ContactInternationalNumber")%>' DataSourceID="SqlDataSource3" DataValueField="CountryCode" DataTextField="Country" />
<br />
<asp:RequiredFieldValidator Display="Dynamic" ErrorMessage="* Required Field" ForeColor="Red" ControlToValidate="ddlCountryCodes" runat="server" />
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ContactPhoneNumber" HeaderText="Contact Phone">
<ItemTemplate>
<asp:Label Text='<%# Eval("ContactPhoneNumber")%>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox ID="txtPhoneNumber" runat="server" MaxLength="100" Text='<%# Bind("ContactPhoneNumber")%>' /><br />
<%--<telerik:RadMaskedTextBox ID="radMskTxtPhoneNumber" runat="server" SelectionOnFocus="SelectAll" PromptChar="_" Mask="(###) ###-####" Text='<%# Bind("ContactPhoneNumber")%>' />--%>
<asp:RequiredFieldValidator Display="Dynamic" ErrorMessage="* Required Field" ForeColor="Red" ControlToValidate="txtPhoneNumber" runat="server" />
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="CreatedBy" HeaderText="Created By" ReadOnly="true" SortExpression="CreatedBy" UniqueName="CreatedBy" FilterControlAltText="Filter CreatedBy column">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CreateDate" HeaderText="Create Date" DataFormatString="{0:MM-dd-yyyy}" ReadOnly="true" SortExpression="CreateDate" UniqueName="CreateDate" FilterControlAltText="Filter CreateDate column" DataType="System.DateTime">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastModifiedBy" HeaderText="Last Modified By" ReadOnly="true" SortExpression="LastModifiedBy" UniqueName="LastModifiedBy" FilterControlAltText="Filter LastModifiedBy column">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastModifiedDate" HeaderText="Last Modified Date" ReadOnly="true" DataFormatString="{0:MM-dd-yyyy}" SortExpression="LastModifiedDate" UniqueName="LastModifiedDate" FilterControlAltText="Filter LastModifiedDate column" DataType="System.DateTime">
<ColumnValidationSettings>
<ModelErrorMessage Text=""></ModelErrorMessage>
</ColumnValidationSettings>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Please try with the below code snippet.
Protected Sub RadGrid1_ItemInserted(source As Object, e As GridInsertedEventArgs)
Dim editformItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
Dim txtName As RadTextBox = DirectCast(editformItem.FindControl("txtName"), RadTextBox)
Dim ddlContactType As RadDropDownList = DirectCast(editformItem.FindControl("ddlContactType"), RadDropDownList)
' You can access textbox and dropdownlist here
End Sub
OR
Protected Sub RadGrid1_ItemInserted(source As Object, e As GridInsertedEventArgs)
Dim editformItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
Dim txtName As RadTextBox = DirectCast(editformItem.FindControl("txtName"), RadTextBox)
Dim ddlContactType As RadDropDownList = DirectCast(editformItem.FindControl("ddlContactType"), RadDropDownList)
' You can access textbox and dropdownlist here
End Sub
Let me know if any concern.
When I edit items in a Listview from a Dropdown list and press the standard update button the data is not updating.
This is the structure of my database.
CREATE TABLE [dbo].[Assets]
(
[AssetID] [INT] IDENTITY(20000,1) PRIMARY KEY NOT NULL,
[Asset] NVARCHAR(20) NOT NULL,
[Symbol] NVARCHAR(20) NULL,
[AssetType] NVARCHAR(20) CONSTRAINT chk_asttype CHECK (assettype IN ('Currencies',
'Indices',
'Stocks',
'Commodities')) NOT NULL,CREATE TABLE[dbo].[times]
(
timeid [INT] IDENTITY(20010,1) PRIMARY KEY NOT NULL,
timevalues NVARCHAR (15) DEFAULT '15 Minutes' NOT NULL
)CREATE TABLE [dbo].[results]
(
[resultid] [INT] IDENTITY(20016,1) PRIMARY KEY NOT NULL,
[result] [NVARCHAR](10)CONSTRAINT chk_result CHECK (result IN ('Won',
'Lost',
'Draw',
'Prepare',
'New Signal'))
)CREATE TABLE [dbo].[binarysignals]
(
[signalid] [INT] IDENTITY(30000,1) PRIMARY KEY NOT NULL,
[assetid] [INT]CONSTRAINT fk_binastid FOREIGN KEY REFERENCES assets(assetid) NOT NULL,
[signaldate][DATE] DEFAULT Getdate() NOT NULL,
[direction][VARCHAR](4) CONSTRAINT chk_bindirection CHECK (direction IN ('Call',
'Put')) DEFAULT NULL,
[strikeprice] [SMALLMONEY] DEFAULT NULL,
[expiryprice] [SMALLMONEY] DEFAULT NULL,
[starttime][SMALLDATETIME] DEFAULT NULL,
[expirytime][NVARCHAR](20) DEFAULT NULL,
[resultid] [INT]CONSTRAINT fk_binresid FOREIGN KEY REFERENCES results(resultid) DEFAULT 20016 NOT NULL,
[lastupdatedtime][SMALLDATETIME] DEFAULT Getdate() NOT NULL,
)
And here is my ASP.Net markup code
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<script src="Scripts/jquery-1.9.1.min.js"></script>
$(document).ready(function () {
ShowTime();
});
function ShowTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML = dt.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000);
}
<div>
<label id="lblTime" style="font-weight: bold"></label>
<br />
<asp:SqlDataSource ID="BO" runat="server" ConnectionString="<%$ ConnectionStrings:Signals2UConnectionString %>"
DeleteCommand="DELETE FROM [BinarySignals] WHERE [SignalID] = #SignalID" InsertCommand="INSERT INTO [BinarySignals] ([AssetID]) VALUES (#AssetID)" SelectCommand="SELECT [SignalID], BinarySignals.AssetID ,[Asset], [SignalDate], [Direction], [StrikePrice], [ExpiryPrice], [StartTime], [ExpiryTime], [Result],Results.ResultID FROM [BinarySignals]
INNER JOIN Assets On BinarySignals.AssetID=Assets.AssetID
INNER JOIN Results On BinarySignals.ResultID=Results.ResultID
ORDER BY BinarySignals.AssetID DESC"
UpdateCommand="UPDATE [BinarySignals] SET [AssetID] = #AssetID, [SignalDate] = #SignalDate, [Direction] = #Direction, [StrikePrice] = #StrikePrice, [ExpiryPrice] = #ExpiryPrice, [StartTime] = #StartTime, [ExpiryTime] = #ExpiryTime, [ResultID] = #ResultID WHERE [SignalID] = #SignalID">
<DeleteParameters>
<asp:Parameter Name="SignalID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="AssetID" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="AssetID" Type="Int32" />
<asp:Parameter DbType="Date" Name="SignalDate" />
<asp:Parameter Name="Direction" Type="String" />
<asp:Parameter Name="StrikePrice" Type="Decimal" />
<asp:Parameter Name="ExpiryPrice" Type="Decimal" />
<asp:Parameter Name="StartTime" Type="DateTime" />
<asp:Parameter Name="ExpiryTime" Type="String" />
<asp:Parameter Name="ResultID" Type="Int32" />
<asp:Parameter Name="SignalID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="Results" runat="server" ConnectionString="<%$ ConnectionStrings:Signals2UConnectionString %>" SelectCommand="SELECT [Result], [ResultID] FROM [Results]"></asp:SqlDataSource>
<asp:ListView ID="ListView1" runat="server" DataSourceID="BO" GroupItemCount="3" InsertItemPosition="LastItem">
<AlternatingItemTemplate>
<td id="Td1" runat="server" style="">SignalID:
<asp:Label ID="SignalIDLabel" runat="server" Text='<%# Eval("SignalID") %>' />
<br />
Asset:
<asp:Label ID="AssetLabel" runat="server" Text='<%# Eval("Asset") %>' />
<br />
SignalDate:
<asp:Label ID="SignalDateLabel" runat="server" Text='<%# Eval("SignalDate","{0:yyyy-MM-dd}") %>' />
<br />
Direction:
<asp:Label ID="DirectionLabel" runat="server" Text='<%# Eval("Direction") %>' />
<br />
StrikePrice:
<asp:Label ID="StrikePriceLabel" runat="server" Text='<%# Eval("StrikePrice") %>' />
<br />
ExpiryPrice:
<asp:Label ID="ExpiryPriceLabel" runat="server" Text='<%# Eval("ExpiryPrice") %>' />
<br />
StartTime:
<asp:Label ID="StartTimeLabel" runat="server" Text='<%# Eval("StartTime") %>' />
<br />
ExpiryTime:
<asp:Label ID="ExpiryTimeLabel" runat="server" Text='<%# Eval("ExpiryTime") %>' />
<br />
Result:
<asp:Label ID="ResultLabel" runat="server" Text='<%# Eval("Result") %>' />
<br />
ResultID:
<asp:Label ID="ResultIDLabel" runat="server" Text='<%# Eval("ResultID") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
</td>
</AlternatingItemTemplate>
<EditItemTemplate>
<td id="Td2" runat="server" style="">SignalID:
Asset:
<asp:TextBox ID="AssetTextBox" runat="server" ReadOnly="true" Text='<%# Bind("Asset") %>' />
<br />
SignalDate:
<asp:TextBox ID="SignalDateTextBox" runat="server" Text='<%# Bind("SignalDate") %>' />
<br />
Direction:
<asp:TextBox ID="DirectionTextBox" runat="server" Text='<%# Bind("Direction") %>' />
<br />
StrikePrice:
<asp:TextBox ID="StrikePriceTextBox" runat="server" Text='<%# Bind("StrikePrice") %>' />
<br />
ExpiryPrice:
<asp:TextBox ID="ExpiryPriceTextBox" runat="server" Text='<%# Bind("ExpiryPrice") %>' />
<br />
StartTime:
<asp:TextBox ID="StartTimeTextBox" runat="server" Text='<%# Bind("StartTime") %>' />
<br />
ExpiryTime:
<asp:TextBox ID="ExpiryTimeTextBox" runat="server" Text='<%# Bind("ExpiryTime") %>' />
<br />
Result:
<asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="Outcome" DataTextField="Result" DataValueField="ResultID" SelectedValue='<%#Bind("ResultID") %>'></asp:DropDownList>
<br />
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<br />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
<br />
</td>
</EditItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<EmptyItemTemplate>
<td id="Td3" runat="server" />
</EmptyItemTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server"></td>
</tr>
</GroupTemplate>
<InsertItemTemplate>
<td id="Td4" runat="server" style="">Asset:
<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="Assets" DataTextField="Asset" DataValueField="AssetID" AutoPostBack="True" SelectedValue='<%# Bind("AssetID") %>'>
</asp:DropDownList>
<br />
SignalDate:
<asp:Label ID="SignalDateLabel" runat="server" Text='<%# Bind("SignalDate") %>' />
<br />
Direction:
<asp:TextBox ID="DirectionTextBox" runat="server" Text='<%# Bind("Direction") %>' />
<br />
StrikePrice:
<asp:TextBox ID="StrikePriceTextBox" runat="server" Text='<%# Bind("StrikePrice") %>' />
<br />
ExpiryPrice:
<asp:TextBox ID="ExpiryPriceTextBox" runat="server" Text='<%# Bind("ExpiryPrice") %>' />
<br />
StartTime:
<asp:TextBox ID="StartTimeTextBox" runat="server" Text='<%# Bind("StartTime") %>' />
<br />
ExpiryTime:
<asp:TextBox ID="ExpiryTimeTextBox" runat="server" Text='<%# Bind("ExpiryTime") %>' />
<br />
Result:
<asp:TextBox ID="ResultTextBox" runat="server" Text='<%# Bind("Result") %>' />
<br />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<br />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
<br />
</td>
</InsertItemTemplate>
<ItemTemplate>
<td id="Td5" runat="server" style="">SignalID:
<asp:Label ID="SignalIDLabel" runat="server" Text='<%# Eval("SignalID") %>' />
<br />
Asset:
<asp:Label ID="AssetLabel" runat="server" Text='<%# Eval("Asset") %>' />
<br />
SignalDate:
<asp:Label ID="SignalDateLabel" runat="server" Text='<%# Eval("SignalDate","{0:yyyy-MM-dd}") %>' />
<br />
Direction:
<asp:Label ID="DirectionLabel" runat="server" Text='<%# Eval("Direction") %>' />
<br />
StrikePrice:
<asp:Label ID="StrikePriceLabel" runat="server" Text='<%# Eval("StrikePrice") %>' />
<br />
ExpiryPrice:
<asp:Label ID="ExpiryPriceLabel" runat="server" Text='<%# Eval("ExpiryPrice") %>' />
<br />
StartTime:
<asp:Label ID="StartTimeLabel" runat="server" Text='<%# Eval("StartTime") %>' />
<br />
ExpiryTime:
<asp:Label ID="ExpiryTimeLabel" runat="server" Text='<%# Eval("ExpiryTime") %>' />
<br />
Result:
<asp:Label ID="ResultLabel" runat="server" Text='<%# Eval("Result") %>' />
<br />
ResultID:
<asp:Label ID="ResultIDLabel" runat="server" Text='<%#Eval("ResultID") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
</td>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td6" runat="server">
<table id="groupPlaceholderContainer" runat="server" border="0" style="">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr2" runat="server">
<td id="Td7" runat="server" style=""></td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<td id="Td8" runat="server" style="">SignalID:
<asp:Label ID="SignalIDLabel" runat="server" Text='<%# Eval("SignalID") %>' />
<br />
AssetID:
<asp:Label ID="AssetIDLabel" runat="server" Text='<%# Eval("AssetID") %>' />
<br />
Asset:
<asp:Label ID="AssetLabel" runat="server" Text='<%# Eval("Asset") %>' />
<br />
SignalDate:
<asp:Label ID="SignalDateLabel" runat="server" Text='<%# Eval("SignalDate","{0:yyyy-MM-dd}") %>' />
<br />
Direction:
<asp:Label ID="DirectionLabel" runat="server" Text='<%# Eval("Direction") %>' />
<br />
StrikePrice:
<asp:Label ID="StrikePriceLabel" runat="server" Text='<%# Eval("StrikePrice") %>' />
<br />
ExpiryPrice:
<asp:Label ID="ExpiryPriceLabel" runat="server" Text='<%# Eval("ExpiryPrice") %>' />
<br />
StartTime:
<asp:Label ID="StartTimeLabel" runat="server" Text='<%# Eval("SignalDate") %>' />
<br />
ExpiryTime:
<asp:Label ID="ExpiryTimeLabel" runat="server" Text='<%# Eval("ExpiryTime") %>' />
<br />
Result:
<asp:Label ID="ResultLabel" runat="server" Text='<%# Eval("Result") %>' />
<br />
ResultID:
<asp:Label ID="ResultIDLabel" runat="server" Text='<%# Eval("ResultID") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
</td>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="Assets" runat="server" ConnectionString="<%$ ConnectionStrings:Signals2UConnectionString %>" SelectCommand="SELECT [AssetID], [Asset], [AssetType], [Symbol] FROM [Assets]"></asp:SqlDataSource>
<asp:SqlDataSource ID="times" runat="server" ConnectionString="<%$ ConnectionStrings:Signals2UConnectionString %>" SelectCommand="SELECT DISTINCT [TimeID], [TimeValues] FROM [Times]"></asp:SqlDataSource>
<asp:SqlDataSource ID="Outcome" runat="server" ConnectionString="<%$ ConnectionStrings:Signals2UConnectionString %>" SelectCommand="SELECT [ResultID], [Result] FROM [Results]"></asp:SqlDataSource>
</div>
I try to update the Results value which is a Foreign key stored in the Binary Signals table coming from the Results table. Result field is used as the display text and the ResultId as the value for the dropdown list
Solved. The below was missing from the EditItemTemplate
<asp:Label ID="SignalIDLabel" runat="server" Text='<%# Bind("SignalID")%>'/>
Is it possible to line break a listview control set to single row in visual studio similar to a wordwrap? So the line break occurs when a certain width is exceeded by the text, not where a certain number of results is exceeded (eg displaying the results as columns)
ie:
Matthew Chrinstina Fankie Daniel Angela James Simon Laura
as
Matthew Chrinstina Fankie
Daniel Angela James Simon
Laura
not
Matthew Chrinstina Fankie
Daniel Angela James
Simon Laura
Here is my asp which displays as a single row with alternating values embolden:
<div class="ExcludedStudent">
<asp:Label ID="lvlExcludedStudents" runat="server" CssClass="boldlabel" Text="Students excluded from the Progress Measure:"></asp:Label>
<asp:ListView ID="lvExcludedStudents" runat="server" DataSourceID="dsExcludedStudents">
<AlternatingItemTemplate>
<td runat="server" style="">
<asp:Label ID="Column1Label" runat="server" Text='<%# Eval("Column1") %>' Font-Bold="True" />
<br />
</td>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table style="">
<tr>
<td>None.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<td runat="server" style="">
<asp:Label ID="Column1Label" runat="server" Text='<%# Eval("Column1") %>' />
<br />
</td>
</ItemTemplate>
<LayoutTemplate>
<table runat="server" border="0" style="">
<tr runat="server" id="itemPlaceholderContainer">
<td runat="server" id="itemPlaceholder">
</td>
</tr>
</table>
<div style="">
</div>
</LayoutTemplate>
</asp:ListView>
<asp:SqlDataSource ID="dsExcludedStudents" runat="server" ConnectionString="<%$ ConnectionStrings:MaltingsConnectionString %>" SelectCommand="spExcludedStudents" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="DdlYear" Name="StuYear" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ddlDataCollection" Name="DataCollection" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DdlSubject" Name="SubjectName" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DdlTeachingGroup" Name="TeachingGroup" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ddlSubgroup" Name="Subgroup" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
I found exactly what I was looking for here:
How to display UL elements as a flat comma-separated list
First set the listview to a bulleted list and then add the below to the CSS.
/*css to comma separate the unordered list*/
ul li{
display:block;
float:left;
_display:inline;
_float:none;
}
ul li::before{
content:",";
white-space:pre;
}
ul li:first-child::before{
content:"";
}
ul li:last-child::before{
content:" and";
white-space:pre;
}
ul + *{
clear:left;
}
this my code in my user control's designer file
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ucImageList.ascx.cs"
Inherits="Pariwaar.UserControl.ucImageList" %>
<asp:ScriptManagerProxy ID="ajaxScriptManagerProxy" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:HiddenField ID="hidUserId" runat="server" />
<asp:HiddenField ID="hidAlbumId" runat="server" />
<table>
<tr>
<td>
<asp:FileUpload ID="fvUploadFile" runat="server" EnableViewState="true" />
<asp:LinkButton ID="AddImageInfoButton" CssClass="blueLink" runat="server" Text="Upload"
OnClick="AddImageInfoButton_Click"></asp:LinkButton>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="DtLstImageList" runat="server" DataSourceID="odsImageList" OnItemCommand="DtLstImageList_ItemCommand"
EnableTheming="true" RepeatColumns="4" RepeatDirection="Horizontal">
<ItemTemplate>
<ul>
<li style="display: block; text-align: center;">
<asp:ImageButton ID="ImgBtnImagePath" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>'
ImageAlign="Middle" Width="100" Height="100" CommandName="ViewImage" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ImageId")%>' />
</li>
<li style="display: block;">
<asp:Button ID="UpdateCoverPageImage" runat="server" Text="Set as Cover Page" CssClass="inputButtonWithoutpadding"
CommandName="SetAsCoverPage" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ImageId")%>' />
</li>
</ul>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="odsImageList" runat="server" SelectMethod="GetImageInfo"
TypeName="Pariwaar.Controller.GallaryHandler" DeleteMethod="DeleteImageInfo">
<DeleteParameters>
<asp:Parameter Name="ImageId" Type="Int64" />
</DeleteParameters>
<SelectParameters>
<asp:Parameter DefaultValue="0" Name="ImageId" Type="Int64" />
<asp:ControlParameter ControlID="hidAlbumId" Name="AlbumId" PropertyName="Value"
Type="Int64" DefaultValue="0" />
</SelectParameters>
</asp:ObjectDataSource>
i am not getting Fiepath/name and Fileupload controls' posted file property is null
i am checking fvFileUpload.Postedfile in click event of AddImageInfoButton
can anybody please tell me what i am doing wrong in this code...
-thanks in advance
File uploads are not supported in async postbacks, such as when you use the UpdatePanel. Read this blog post for more details.
Here are two proposed workarounds:
Have a dedicated "Upload" button that does a regular postback instead of an async postback. You can achieve this using several techniques: Have the button be outside all UpdatePanels; have the button be the target of an UpdatePanel's PostBackTrigger; or call ScriptManager.RegisterPostBackControl() on it.
Have a dedicated file upload page that doesn't have any UpdatePanels. Many web sites already do this anyway.