how can i use datapager with datalist? - asp.net

i have a datalist and a datapager but when i run my program it have error.
Control 'DataList1' does not implement IPageableItemContainer.
what is problem?
<asp:DataList ID="DataList1" runat="server" DataKeyField="id"
DataSourceID="SqlDataSource1">
<ItemTemplate>
id:
<asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
<br />
name:
<asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
<br />
tedad:
<asp:Label ID="tedadLabel" runat="server" Text='<%# Eval("tedad") %>' />
<br />
group_id:
<asp:Label ID="group_idLabel" runat="server" Text='<%# Eval("group_id") %>' />
<br />
VDate:
<asp:Label ID="VDateLabel" runat="server" Text='<%# Eval("VDate") %>' />
<br />
KDate:
<asp:Label ID="KDateLabel" runat="server" Text='<%# Eval("KDate") %>' />
<br />
gheimat:
<asp:Label ID="gheimatLabel" runat="server" Text='<%# Eval("gheimat") %>' />
<br />
details:
<asp:Label ID="detailsLabel" runat="server" Text='<%# Eval("details") %>' />
<br />
imgae:
<asp:Label ID="imgaeLabel" runat="server" Text='<%# Eval("imgae") %>' />
<br />
"
SelectCommand="SELECT * FROM [Tbl_Kala_Group_No]">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID = "DataList1" PageSize = "4" QueryStringField = "page" >
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
</Fields>
</asp:DataPager>

Datapager control does not support for DataList. it works with ListView.
so, Paging for DataList, you have create paging dynamically.
Just give in google : paging for Datalist, you will find lots of resource. Thank you.

Related

RequiredFieldValidator is not Valid even if there is values

I have a Page Fruit that has a UpdatePanel P1 and a ModalWIndow (outside of the updatepanel). I have a Page Apple with An UpdatePanel P2. ModalWindow on Page fruit will add Page Apple on demand.
Now, In the Apple Page
I have a GridView with EditItemTemplate and FooterItemtemplate for lets say 5 columns. Both of them have RegularExpressionValidator and RequiredFieldValidtor each separated by ValidationGroup. For EditItemTemplate everything is on point.
For FooterItemTemplate, the button won't do postback even though all the validation is met.
The footer template looks like this for the column of interest
<FooterTemplate>
<asp:TextBox ID="vendorAdd" runat="server" Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator66" ControlToValidate="vendorAdd" ValidationGroup="AddValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid VendorName" />
<asp:RequiredFieldValidator id = "RegularExpressionValidator67" ValidationGroup="AddValidation" ControlToValidate="vendorAdd"
runat="server" ErrorMessage="VendorName Required" />
</FooterTemplate>
There is no message saying this failed. I removed the all the other validation on other footer column than shown above. I added on the button to stop validation. And in Server side added this
Page.Validate("AddValidation");
var b = Page.IsValid;
var notValidValidators = Page.Validators.Cast<IValidator>().Where(v => !v.IsValid);`
Here in the debugger the notValidValidator says that RequiredFieldValidator is not Valid. I don't see why though, I have a value and there is no message on the front end.
Update Panel on Apple Page full Code is below
<asp:UpdatePanel ID="ackPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="ackedItems" runat="server" Width="720" Visible="true" DataKeyNames="AckId" RowStyle-Height="10px"
AutoGenerateColumns="False" BorderStyle="Dotted" BorderWidth="1px" CellPadding="2"
BackColor="White" BorderColor="#CCCCCC" HorizontalAlign="Left" AllowPaging="false"
ShowFooter="true" OnRowUpdating="AckedItems_RowUpdating" OnRowDeleting="AckedItems_RowDeleting"
OnRowEditing="AckedItems_RowEditing" OnRowCommand="AckedItems_RowCommand" OnRowDataBound="AckedItems_RowDataBound">
<RowStyle ForeColor="#000066" Font-Size="8pt" />
<HeaderStyle ForeColor="#336699" Font-Size="8pt" CssClass="GridViewHeader" Height="20px" />
<AlternatingRowStyle CssClass="GridViewAltStyle" />
<Columns >
<asp:BoundField DataField="AckId" ReadOnly="true" Visible="false" />
<asp:TemplateField HeaderText="Vendor" HeaderStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="vendor" runat="server" Text='<%# Bind("VendorName") %>' Width="95%"/>
</ItemTemplate>
<EditItemTemplate >
<asp:TextBox ID="vendorEdit" runat="server" Text='<%# Bind("VendorName") %>' Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="vendorEdit" ValidationGroup="EditValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid VendorName" />
<asp:RequiredFieldValidator id = "Ab" ValidationGroup="EditValidation" ControlToValidate="vendorEdit"
runat="server" ErrorMessage="VendorName Required" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="vendorAdd" runat="server" Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator66" ControlToValidate="vendorAdd" ValidationGroup="AddValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid VendorName" />
<asp:RequiredFieldValidator id = "RegularExpressionValidator67" ValidationGroup="AddValidation" ControlToValidate="vendorAdd"
runat="server" ErrorMessage="VendorName Required" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount" HeaderStyle-Width="10px">
<ItemTemplate>
<asp:Label ID="amount" DataFormatString = "{0:C2}" runat="server" Text='<%# Bind("Amount") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="amountEdit" runat="server" Text='<%# Bind("Amount") %>' Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" ControlToValidate="amountEdit" ValidationGroup="EditValidation"
ValidationExpression="\d*(\.\d*)?" runat="server" ErrorMessage="Invalid Amount" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="EditValidation" ControlToValidate="amountEdit"
runat="server" ErrorMessage="Amount Required" />
</EditItemTemplate>
<FooterTemplate >
<asp:TextBox ID="amountAdd" runat="server"
Width="95%" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" ControlToValidate="amountAdd" ValidationGroup="AddValidation"
ValidationExpression="\d*(\.\d*)?" runat="server" ErrorMessage="Invalid Amount" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type">
<ItemTemplate>
<asp:Label ID="type" runat="server" Text='<%# Bind("Type") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="typeEdit" runat="server" Text='<%# Bind("Type") %>' Width="95%" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" ControlToValidate="typeEdit" ValidationGroup="EditValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid Type" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" ValidationGroup="EditValidation" ControlToValidate="typeEdit"
runat="server" ErrorMessage="Type Required" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="typeAdd" runat="server" Width="95%" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" ControlToValidate="typeAdd"
ValidationGroup="AddValidation" ValidationExpression="\w*" runat="server" ErrorMessage="Invalid Type" />
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ProgNum" ReadOnly="true" HeaderText="ProgNum" ControlStyle-Width="95%" />
<asp:TemplateField HeaderText="AckDate">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Convert.ToDateTime(Eval("AckDate")).ToString("MM/dd/yyyy") %>' Width="95%"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Notes" >
<ItemTemplate>
<asp:Label ID="notes" runat="server" Text='<%# Bind("Notes") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="notesEdit" Text='<%# Bind("Notes") %>' runat="server" Width="95%"/>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="notesAdd" runat="server" Width="95
%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActivityDate">
<ItemTemplate>
<asp:Label ID="activityDate" runat="server" Text='<%#Convert.ToDateTime(Eval("activityDate")).ToString("MM/dd/yyyy") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="activityDateEdit" Text='<%#Convert.ToDateTime(Eval("activityDate")).ToString("MM/dd/yyyy") %>' runat="server" CssClass="date" Width="95%" />
<asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date" Operator="DataTypeCheck" ValidationGroup="EditValidation"
ControlToValidate="activityDateEdit" ErrorMessage="Invalid Date" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" ValidationGroup="EditValidation" ControlToValidate="activityDateEdit"
runat="server" ErrorMessage="Date Required" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="activityDateAdd" runat="server" CssClass="date" Width="95%"/>
<asp:CompareValidator ID="CompareValidator2" runat="server" Type="Date" Operator="DataTypeCheck" ValidationGroup="AddValidation"
ControlToValidate="activityDateAdd" ErrorMessage="Invalid Date" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IsVoid">
<ItemTemplate>
<asp:CheckBox ID="isVoid" runat="server" Checked='<%# Eval("IsVoid") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="isVoidEdit" runat="server" Checked='<%# Eval("IsVoid") %>' Width="95%" />
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="isVoidAdd" runat="server" Width="95%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VoidReason">
<ItemTemplate>
<asp:Label ID="voidReason" runat="server" Text='<%# Bind("VoidReason") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="voidReasonEdit" runat="server" Width="95%" />
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="voidReasonAdd" runat="server" Width="95%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="false" CommandName="Edit"
Text="<img border=0 src=../Theme/Main/Images/edit.gif alt=Edit>" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="false" CommandName="Delete"
OnClientClick="if(!confirm('Do You Really want to Delete this Order Item?')) return false;"
Text="<img border=0 src=../Theme/Main/Images/delete.gif alt=Delete>" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbAdd" runat="server" CausesValidation="true" CommandName="Update"
ValidationGroup="EditValidation" Text="<img border=0 src=../Theme/Main/Images/check.gif alt=Update>" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="false" CommandName="Cancel"
Text="<img border=0 src=../Theme/Main/Images/delete.gif alt=Cancel>" />
</EditItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Top" />
<FooterTemplate>
<asp:LinkButton ID="lbAdd" runat="server" CausesValidation="false" CommandName="Add"
ValidationGroup="AddValidation" Text="<img border=0 src=../Theme/Main/Images/check.gif alt=Add>" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="false" CommandName="Cancel"
Text="<img border=0 src=../Theme/Main/Images/delete.gif alt=Cancel>" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:TextBox ID="vendorEdit" runat="server" Text='<%# Bind("Vendor") %>' CssClass="InputTextBox"
Width="100px" />
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lbEdit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

ASP.NET Listview not saving edit

I am trying to use a listview to display and update marks.
The data displays without any issues, however when I click edit, then insert data and try to save the changes, the listview fails to do so and loads in the same state is was prior to the update attempt. Any ideas what is going on?
<asp:SqlDataSource ID="StudentResultsDS" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>"
SelectCommand="SELECT Module_Info.ModuleTitle, Module_Info.UserID, Module_Info.ModuleCode, Modules.ModuleMarks, Modules.MarkID, Modules.ExamMark, Modules.AssignmentMark, Users.SNumber, Lecturer_Records.UserID AS Expr1 FROM Module_Info INNER JOIN Modules ON Module_Info.ModuleID = Modules.ModuleID INNER JOIN Users ON Modules.UserID = Users.UserID INNER JOIN Lecturer_Records ON Users.UserID = Lecturer_Records.UserID WHERE (Lecturer_Records.UserID = #UserID)" UpdateCommand="UPDATE [Modules] SET [ModuleMarks]=#ModuleMarks WHERE [MarkID]=#MarkID" >
<UpdateParameters>
<asp:FormParameter Name="ModuleMarks" Type="String" />
<asp:FormParameter Name="MarkID" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="grabUserID" />
</SelectParameters>
</asp:SqlDataSource>
<!-- list view to display results-->
<header class="jumbotron hero-spacer">
<asp:ListView runat="server" ID="listviewid" DataSourceID="StudentResultsDS" DataKeyNames="ModuleMarks">
<AlternatingItemTemplate>
<span style="">ModuleTitle:
<asp:Label ID="ModuleTitleLabel" runat="server" Text='<%# Eval("ModuleTitle") %>' />
<br />
UserID:
<asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
<br />
ModuleCode:
<asp:Label ID="ModuleCodeLabel" runat="server" Text='<%# Eval("ModuleCode") %>' />
<br />
ModuleMarks:
<asp:Label ID="ModuleMarksLabel" runat="server" Text='<%# Eval("ModuleMarks") %>' />
<br />
MarkID:
<asp:Label ID="MarkIDLabel" runat="server" Text='<%# Eval("MarkID") %>' />
<br />
ExamMark:
<asp:Label ID="ExamMarkLabel" runat="server" Text='<%# Eval("ExamMark") %>' />
<br />
AssignmentMark:
<asp:Label ID="AssignmentMarkLabel" runat="server" Text='<%# Eval("AssignmentMark") %>' />
<br />
SNumber:
<asp:Label ID="SNumberLabel" runat="server" Text='<%# Eval("SNumber") %>' />
<br />
Expr1:
<asp:Label ID="Expr1Label" runat="server" Text='<%# Eval("Expr1") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
<br />
</span>
</AlternatingItemTemplate>
<EditItemTemplate>
<span style="">ModuleTitle:
<asp:TextBox ID="ModuleTitleTextBox" runat="server" Text='<%# Bind("ModuleTitle") %>' />
<br />
UserID:
<asp:TextBox ID="UserIDTextBox" runat="server" Text='<%# Bind("UserID") %>' />
<br />
ModuleCode:
<asp:TextBox ID="ModuleCodeTextBox" runat="server" Text='<%# Bind("ModuleCode") %>' />
<br />
ModuleMarks:
<asp:TextBox ID="ModuleMarksTextBox" runat="server" Text='<%# Bind("ModuleMarks") %>' />
<br />
MarkID:
<asp:Label ID="MarkIDLabel1" runat="server" Text='<%# Eval("MarkID") %>' />
<br />
ExamMark:
<asp:TextBox ID="ExamMarkTextBox" runat="server" Text='<%# Bind("ExamMark") %>' />
<br />
AssignmentMark:
<asp:TextBox ID="AssignmentMarkTextBox" runat="server" Text='<%# Bind("AssignmentMark") %>' />
<br />
SNumber:
<asp:TextBox ID="SNumberTextBox" runat="server" Text='<%# Bind("SNumber") %>' />
<br />
Expr1:
<asp:TextBox ID="Expr1TextBox" runat="server" Text='<%# Bind("Expr1") %>' />
<br />
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
<br />
<br />
</span>
</EditItemTemplate>
<EmptyDataTemplate>
<span>No data was returned.</span>
</EmptyDataTemplate>
<InsertItemTemplate>
<span style="">ModuleTitle:
<asp:TextBox ID="ModuleTitleTextBox" runat="server" Text='<%# Bind("ModuleTitle") %>' />
<br />
UserID:
<asp:TextBox ID="UserIDTextBox" runat="server" Text='<%# Bind("UserID") %>' />
<br />
ModuleCode:
<asp:TextBox ID="ModuleCodeTextBox" runat="server" Text='<%# Bind("ModuleCode") %>' />
<br />
ModuleMarks:
<asp:TextBox ID="ModuleMarksTextBox" runat="server" Text='<%# Bind("ModuleMarks") %>' />
<br />
ExamMark:
<asp:TextBox ID="ExamMarkTextBox" runat="server" Text='<%# Bind("ExamMark") %>' />
<br />
AssignmentMark:
<asp:TextBox ID="AssignmentMarkTextBox" runat="server" Text='<%# Bind("AssignmentMark") %>' />
<br />
SNumber:
<asp:TextBox ID="SNumberTextBox" runat="server" Text='<%# Bind("SNumber") %>' />
<br />
Expr1:
<asp:TextBox ID="Expr1TextBox" runat="server" Text='<%# Bind("Expr1") %>' />
<br />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
<br />
<br />
</span>
</InsertItemTemplate>
<ItemTemplate>
<span style="">ModuleTitle:
<asp:Label ID="ModuleTitleLabel" runat="server" Text='<%# Eval("ModuleTitle") %>' />
<br />
UserID:
<asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
<br />
ModuleCode:
<asp:Label ID="ModuleCodeLabel" runat="server" Text='<%# Eval("ModuleCode") %>' />
<br />
ModuleMarks:
<asp:Label ID="ModuleMarksLabel" runat="server" Text='<%# Eval("ModuleMarks") %>' />
<br />
MarkID:
<asp:Label ID="MarkIDLabel" runat="server" Text='<%# Eval("MarkID") %>' />
<br />
ExamMark:
<asp:Label ID="ExamMarkLabel" runat="server" Text='<%# Eval("ExamMark") %>' />
<br />
AssignmentMark:
<asp:Label ID="AssignmentMarkLabel" runat="server" Text='<%# Eval("AssignmentMark") %>' />
<br />
SNumber:
<asp:Label ID="SNumberLabel" runat="server" Text='<%# Eval("SNumber") %>' />
<br />
Expr1:
<asp:Label ID="Expr1Label" runat="server" Text='<%# Eval("Expr1") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
<br />
</span>
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style="">
<span runat="server" id="itemPlaceholder" />
</div>
<div style="">
</div>
</LayoutTemplate>
<SelectedItemTemplate>
<span style="">ModuleTitle:
<asp:Label ID="ModuleTitleLabel" runat="server" Text='<%# Eval("ModuleTitle") %>' />
<br />
UserID:
<asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
<br />
ModuleCode:
<asp:Label ID="ModuleCodeLabel" runat="server" Text='<%# Eval("ModuleCode") %>' />
<br />
ModuleMarks:
<asp:Label ID="ModuleMarksLabel" runat="server" Text='<%# Eval("ModuleMarks") %>' />
<br />
MarkID:
<asp:Label ID="MarkIDLabel" runat="server" Text='<%# Eval("MarkID") %>' />
<br />
ExamMark:
<asp:Label ID="ExamMarkLabel" runat="server" Text='<%# Eval("ExamMark") %>' />
<br />
AssignmentMark:
<asp:Label ID="AssignmentMarkLabel" runat="server" Text='<%# Eval("AssignmentMark") %>' />
<br />
SNumber:
<asp:Label ID="SNumberLabel" runat="server" Text='<%# Eval("SNumber") %>' />
<br />
Expr1:
<asp:Label ID="Expr1Label" runat="server" Text='<%# Eval("Expr1") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
<br />
</span>
</SelectedItemTemplate>
</asp:ListView>
Try changing it to a gridview which should allow the update to work. Try this code below:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="searchStudentResults" cssClass="table table-hover" AllowSorting="True" OnRowUpdated="GridView1_RowUpdated1" >
<Columns>
<asp:BoundField DataField="StudentNo" HeaderText="StudentNo" SortExpression="StudentNo" ReadOnly="true" />
<asp:BoundField DataField="ExamMark" HeaderText="Exam %" SortExpression="ExamMark" />
<asp:BoundField DataField="AssignmentMark" HeaderText="Assignment %" SortExpression="AssignmentMark" />
<asp:BoundField DataField="ModuleMarks" SortExpression="ModuleMarks" HeaderText="ModuleMarks" ReadOnly="true" DataFormatString="{0:0}" />
<asp:CommandField ShowEditButton="True" ButtonType="Button" EditText="Add Marks" ControlStyle-CssClass="btn btn-primary" ItemStyle-Width="100px" >
<ControlStyle CssClass="btn btn-primary"></ControlStyle>
<ItemStyle Width="100px"></ItemStyle>
</asp:CommandField>
<asp:BoundField DataField="MarkID" ControlStyle-CssClass="hidden" ItemStyle-CssClass="hidden" HeaderStyle-CssClass="hidden" >
<ControlStyle CssClass="hidden"></ControlStyle>
<HeaderStyle CssClass="hidden"></HeaderStyle>
<ItemStyle CssClass="hidden"></ItemStyle>
</asp:BoundField>
</Columns>
<EmptyDataTemplate>
No marks to enter
</EmptyDataTemplate>
</asp:GridView>

System.NullReferenceException was unhandled by user code Object variable or With block variable not set

Help:.....struggling with this null reference. Below is the code any ideas?
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table class="auto-style1">
<tr>
<td> <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="PID" DataSourceID="DetailsSqlDataSource" Height="50px" HorizontalAlign="Center" Width="589px" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<Fields>
<asp:BoundField DataField="PID" HeaderText="PID" InsertVisible="False" ReadOnly="True" SortExpression="PID" Visible="False" />
<asp:TemplateField HeaderText="Address" SortExpression="PAddress">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PAddress") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PAddress") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("PAddress") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="St" HeaderText="St" SortExpression="St" />
<asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Beds" HeaderText="Beds" SortExpression="Beds" />
<asp:BoundField DataField="Bath" HeaderText="Bath" SortExpression="Bath" />
<asp:BoundField DataField="SqFt" HeaderText="SqFt" SortExpression="SqFt" />
<asp:BoundField DataField="MLS" HeaderText="MLS" SortExpression="MLS" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="AgentName" HeaderText="AgentName" SortExpression="AgentName" />
<asp:BoundField DataField="AgentEmail" HeaderText="AgentEmail" SortExpression="AgentEmail" />
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("PhotoPath") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("PhotoPath") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="175px" ImageUrl='<%# Eval("PhotoPath") %>' Width="175px" />
</ItemTemplate>
</asp:TemplateField>
</Fields>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:DetailsView>
</td>
<td valign="top">
<asp:FormView ID="FormView1" runat="server" DataKeyNames="Id" DataSourceID="RequestInfoSqlDataSource" DefaultMode="Insert">
<EditItemTemplate>
FromAddress:
<asp:TextBox ID="FromAddressTextBox" runat="server" Text='<%# Bind("FromAddress") %>' />
<br />
PropertyAddress:
<asp:TextBox ID="PropertyAddressTextBox" runat="server" Text='<%# Bind("PropertyAddress") %>' />
<br />
Phone:
<asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' />
<br />
Message:
<asp:TextBox ID="MessageTextBox" runat="server" Text='<%# Bind("Message") %>' />
<br />
FName:
<asp:TextBox ID="FNameTextBox" runat="server" Text='<%# Bind("FName") %>' />
<br />
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
Id:
<asp:Label ID="IdLabel1" runat="server" Text='<%# Eval("Id") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
<table style="width:100%;">
<tr>
<td colspan="2" style="text-align: center; font-weight: 700">Request Information:</td>
</tr>
<tr>
<td>First Name:</td>
<td>
<asp:TextBox ID="FNameTextBox" runat="server" Text='<%# Bind("FName") %>' Width="128px" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" controltovalidate="FNameTextBox" runat="server" ErrorMessage="Please enter your first name" style="color: #FF0000; font-weight: 700"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" controltovalidate="LNameTextBox" runat="server" ErrorMessage="Please enter your last name" style="font-weight: 700; color: #FF0000"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<asp:TextBox ID="FromAddressTextBox" runat="server" Text='<%# Bind("FromAddress") %>' />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="FromAddressTextBox" runat="server" ErrorMessage="Please enter your email address" style="font-weight: 700; color: #FF0000"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<asp:TextBox ID="PhoneTextBox" runat="server" style="text-align: left" Text='<%# Bind("Phone") %>' />
</td>
</tr>
<tr>
<td>Message:</td>
<td>
<asp:TextBox ID="MessageTextBox" runat="server" Height="189px" Text='<%# "Please Send me Information about: "+Detailsview1.DataItem("paddress") + " " +Detailsview1.DataItem("City") %>' TextMode="MultiLine" Width="198px" />
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Send Request" />
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("PropertyAddress") %>'></asp:TextBox>
</td>
</tr>
</table>
<br />
<br />
<br />
</InsertItemTemplate>
<ItemTemplate>
FromAddress:
<asp:Label ID="FromAddressLabel" runat="server" Text='<%# Bind("FromAddress") %>' />
<br />
PropertyAddress:
<asp:Label ID="PropertyAddressLabel" runat="server" Text='<%# Bind("PropertyAddress") %>' />
<br />
Phone:
<asp:Label ID="PhoneLabel" runat="server" Text='<%# Bind("Phone") %>' />
<br />
Message:
<asp:Label ID="MessageLabel" runat="server" Text='<%# Bind("Message") %>' />
<br />
FName:
<asp:Label ID="FNameLabel" runat="server" Text='<%# Bind("FName") %>' />
<br />
LName:
<asp:Label ID="LNameLabel" runat="server" Text='<%# Bind("LName") %>' />
<br />
Id:
<asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:SqlDataSource ID="RequestInfoSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:GretnaRealtyConnectionString %>" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Id], [FromAddress], [PropertyAddress], [Phone], [Message], [FName], [LName] FROM [RequestInfo] WHERE (([PropertyAddress] = #PropertyAddress) AND ([PropertyAddress] = #PropertyAddress2))" InsertCommand="INSERT INTO [RequestInfo] ([FName], [LName], [FromAddress], [Phone], [Message],[PropertyAddress]) VALUES (#FName, #LName, #FromAddress, #Phone, #Message, #Hiddenfield1)">
<InsertParameters>
<asp:Parameter Name="FName" />
<asp:Parameter Name="LName" />
<asp:Parameter Name="FromAddress" />
<asp:Parameter Name="Phone" />
<asp:Parameter Name="Message" />
<asp:Parameter Name="Hiddenfield1" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DetailsView1" Name="PropertyAddress" PropertyName="SelectedValue" Type="String" DefaultValue="0" />
<asp:QueryStringParameter Name="PropertyAddress2" QueryStringField="Paddress" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
<asp:SqlDataSource ID="DetailsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:GretnaRealtyConnectionString %>" SelectCommand="SELECT [PID], [PAddress], [City], [St], [Zip], [Price], [Beds], [Bath], [SqFt], [MLS], [Description], [AgentName], [AgentEmail], [Status], [PhotoPath] FROM [GretnaRealty] WHERE ([PID] = #PID)">
<SelectParameters>
<asp:QueryStringParameter Name="PID" QueryStringField="PID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
Codebehind:
Imports System.Web.UI.WebControls.GridView
Imports System.Web.UI.WebControls.FormView
Partial Class Details
Inherits System.Web.UI.Page
Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles FormView1.ItemInserted
Dim MessageTextBox As TextBox = CType(Me.DetailsView1.FindControl("Paddress"), TextBox)
e.Values("MessageTextBox") = DetailsView1.DataItem
Dim Paddresstextbox As TextBox = CType(Me.DetailsView1.FindControl("Paddress"), TextBox)
e.Values("Textbox3") = DetailsView1.DataItem
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Automatically select the first row for
'the GridView control to cause the
'FormView control to display data.
If Not IsPostBack Then
GridView1.SelectedIndex = 0
End If
End Sub
I may be missing something, but it looks like you do not actually have a control called "PAddress". You have controls bound to the field PAddress, but not a control with the ID "PAddress". That is probably the source of your problem.
When you use the FindControl method of a control, you need to look for the ID of the inner control, not the field to which it is bound.
Similarly, you are looking for a value called "Textbox3" in the e.Values collection. That's where you should be looking for the field name, i.e. e.Values("PropertyAddress").

Button refuses to work

I have a standard button which should call a method but it just refuses to work and I can't figure out why.
ASP code:
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button
ID="UploadButton" runat="server" onclick="UploadButton_Click" Text="Change Logo" />
Code behind:
protected void UploadButton_Click(object sender, EventArgs e)
{
PasswordLabel.Visible = true;
PasswordLabel.Text = "TEST Before";
Image_Inserting(this);
PasswordLabel.Text = "TEST After";
}
I just added the textbox methods to test it but it doesn't seem to be posting back (even when I remove Image_Inserting call). All other buttons work fine so I don't know why this one won't work.
EDIT: Whole page- Button code towards the bottom
<%# Page Title="" Language="C#" MasterPageFile="~/Standardmaster.Master" AutoEventWireup="true" CodeBehind="VendorAccount.aspx.cs" Inherits="PetShopParadise.Vendor_Pages.VendorAccount" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.style10
{
color: #FF0000;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
<h2>Account Details</h2>
<div id="RegistrationDiv">
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
<EditItemTemplate>
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Address:
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
<br />
Phone_Number:
<asp:TextBox ID="Phone_NumberTextBox" runat="server"
Text='<%# Bind("Phone_Number") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Address:
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
<br />
Phone_Number:
<asp:TextBox ID="Phone_NumberTextBox" runat="server"
Text='<%# Bind("Phone_Number") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
<br />
Address:
<asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>' />
<br />
Phone Number:
<asp:Label ID="Phone_NumberLabel" runat="server"
Text='<%# Bind("Phone_Number") %>' />
<br />
<asp:Button ID="Button3" runat="server" Text="Edit Details" CommandName="Edit" />
<br />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>"
SelectCommand="SELECT [Name], [Address], [Phone_Number] FROM [Vendors] WHERE ([VendorID] = #VendorID)">
<SelectParameters>
<asp:SessionParameter Name="VendorID" SessionField="ID" Type="Decimal" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Table ID="Table1" runat="server" style="text-align:left;">
<asp:TableRow ID="TableRow4" runat="server">
<asp:TableCell ID="TableCell7" runat="server">Password</asp:TableCell><asp:TableCell ID="TableCell8" runat="server">
<asp:TextBox ID="PasswordBox" TextMode="Password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator5"
runat="server"
ControlToValidate="PasswordBox"
Display="None"
Forecolor="Red"
ErrorMessage="Please enter a password." />
</asp:TableCell></asp:TableRow><asp:TableRow ID="TableRow5" runat="server">
<asp:TableCell ID="TableCell9" runat="server">Re-Enter Password</asp:TableCell><asp:TableCell ID="TableCell10" runat="server">
<asp:TextBox ID="PasswordCheckBox" TextMode="Password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator6"
runat="server"
ControlToValidate="PasswordCheckBox"
Display="None"
Forecolor="Red"
ErrorMessage="Please re-enter your password." />
</asp:TableCell></asp:TableRow></asp:Table><asp:Label
ID="PasswordLabel" runat="server" Text="Password" CssClass="style10"></asp:Label><br />
<asp:Button ID="PasswordButton"
runat="server" Text="Update Password" onclick="PasswordButton_Click" /><br />
<asp:SqlDataSource
ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>"
onselecting="SqlDataSource2_Selecting" SelectCommand="SELECT * FROM Vendors"
UpdateCommand="UPDATE [Vendors] SET [Password]=#passwordhash WHERE ([VendorID] = #VendorID)" OnUpdating="Parameters_Updating">
<UpdateParameters>
<asp:Parameter Name="Password" />
<asp:SessionParameter name="VendorID" sessionfield="ID" />
</UpdateParameters>
</asp:SqlDataSource>
<br /><asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button
ID="UploadButton" runat="server" onclick="UploadButton_Click" Text="Change Logo" /></div></asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="bannerContent" runat="server">
</asp:Content>
My guess is that it is causing other (possibly hidden) validation to run. Make sure to set CausesValidation to false.
quote :
*I just added the textbox methods *
I guess our trying to update a Password textBox which you can't.
only by :
PasswordLabel .Attributes["value"] = "aaa";

Nested User Control (ListView) in ListView doesn't get bound

Hi I am trying to implement a nested user control in listview and the user control doesn't get bound.
Here is my code.
<asp:ListView ID="ListViewTaskList" runat="server" DataKeyNames="TaskID"
DataSourceID="SqlDataSourceTaskList" OnItemDataBound="ListViewTaskListItemDataBound" ItemPlaceholderID="itemPlaceholder">
<LayoutTemplate>
<div class="ListView ">
<div style="font-size:2em;color:#555555;margin-bottom:20px;">Task List</div>
<div ID="itemPlaceholder" runat="server">
</div>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="rlvI">
<asp:Label ID="TaskIDLabel" runat="server" Text='<%# Eval("TaskID") %>' />
<asp:Label ID="TaskLabel" runat="server" Text='<%# Eval("Task") %>' />
<asp:Label ID="CreatedDateLabel" runat="server" Text='<%# Eval("CreatedDate") %>' />
<asp:Label ID="UpdatedDateLabel" runat="server" Text='<%# Eval("UpdatedDate") %>' />
<asp:Label ID="TimestampLabel" runat="server" Text='<%# Eval("Timestamp") %>' />
<asp:Label ID="TaskTypeIDLabel" runat="server" Text='<%# Eval("TaskTypeID") %>' />
<asp:Label ID="ProjectTaskStatusIDLabel" runat="server" Text='<%# Eval("ProjectTaskStatusID") %>' />
<asp:Label ID="SystemObjectIDLabel" runat="server" Text='<%# Eval("SystemObjectID") %>' />
<asp:Label ID="SystemObjectRecordIDLabel" runat="server" Text='<%# Eval("SystemObjectRecordID") %>' />
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%# Eval("Active") %>' Enabled="false" />
<asp:Label ID="CreatedByAccountIDLabel" runat="server" Text='<%# Eval("CreatedByAccountID") %>' />
<asp:Label ID="UpdatedByAccountIDLabel" runat="server" Text='<%# Eval("UpdatedByAccountID") %>' />
<asp:Button ID="SelectButton" runat="server" CausesValidation="False" CommandName="Select" CssClass="rlvBSel" Text=" " ToolTip="Select" />
<div>
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' systemObjectRecordID="Comments1Init" />
</div>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div class="rlvA">
<asp:Label ID="TaskIDLabel" runat="server" Text='<%# Eval("TaskID") %>' />
<asp:Label ID="TaskLabel" runat="server" Text='<%# Eval("Task") %>' />
<asp:Label ID="CreatedDateLabel" runat="server"
Text='<%# Eval("CreatedDate") %>' />
<asp:Label ID="UpdatedDateLabel" runat="server"
Text='<%# Eval("UpdatedDate") %>' />
<asp:Label ID="TimestampLabel" runat="server"
Text='<%# Eval("Timestamp") %>' />
<asp:Label ID="TaskTypeIDLabel" runat="server"
Text='<%# Eval("TaskTypeID") %>' />
<asp:Label ID="ProjectTaskStatusIDLabel" runat="server"
Text='<%# Eval("ProjectTaskStatusID") %>' />
<asp:Label ID="SystemObjectIDLabel" runat="server"
Text='<%# Eval("SystemObjectID") %>' />
<asp:Label ID="SystemObjectRecordIDLabel" runat="server"
Text='<%# Eval("SystemObjectRecordID") %>' />
<asp:CheckBox ID="ActiveCheckBox" runat="server"
Checked='<%# Eval("Active") %>' Enabled="false" />
<asp:Label ID="CreatedByAccountIDLabel" runat="server"
Text='<%# Eval("CreatedByAccountID") %>' />
<asp:Label ID="UpdatedByAccountIDLabel" runat="server"
Text='<%# Eval("UpdatedByAccountID") %>' />
<asp:Button ID="SelectButton" runat="server" CausesValidation="False"
CommandName="Select" CssClass="rlvBSel" Text=" " ToolTip="Select" />
<div>
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' '<%# Eval("TaskID") %>' />
</div>
</div>
</AlternatingItemTemplate>
``
I have been struggling with this problem for a few days now.
Please help!!
Please help!
if I look at your code, it seems to me that you aren't actually assigning the binding to anything:
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' '<%# Eval("TaskID") %>' />
try instead
<Enet:Comments ID="Comments1" runat="server" systemObjectID='8' YourProperty='<%# Eval("TaskID") %>' />
EDIT: in order to achieve two way data binding, one has to add BindableAttribute to the property on User Control

Resources