|
After converting my first ASP.NET 1.1 project to 2.0, I discovered that one of my button's onclick handler wasn't working. I then proceeded to inspect the InitializeComponent code to find that it was empty. Also there was no declartion of the button control -- or any other control present. Where does ASP.NET v2.0 put this code? Also, is there any way of fixing my problem in code or do I have to delete the button and re-create it so that ASP.NET v2.0 can do it's "under the hood" stuff right?
JSaybrook
|
|
|
|
|
The reason this works has to do with the partial keyword applied to your codebehind class. In addition to turning your .aspx file into a class definition with methods for rendering the page, as it has always done, ASP.NET now also generates a sibling partial class for your codebehind class that contains protected control member variable declarations. Your class is then compiled together with this generated class definition and used as the base class for the class generated for the .aspx file. The end result is that you essentially write codebehind classes the way you always have, but you no longer have to declare (or let the designer declare for you) member variable declarations of server-side controls.
|
|
|
|
|
My basic problem is that one of my buttons, that used to work in the 1.1 version no longer works after the application was converted to 2.0. By that I mean that that the OnClick event doesn't fire. In 1.1 the probable culprit would be a missing "wireup" in InitializeComponent. Now the only reference to the button control that I control appears to be the one in the "html" in the aspx page. Would it help to delete this reference and re-create it? According to what you say it wouldn't appear to matter whether I used an editor or the designer to do this.
jsaybrook
|
|
|
|
|
Are you using the CodeFile keyword in your @Page directive?
What about runat="server" in the button? (Just making sure)
|
|
|
|
|
How do I go about letting my client adjust which columns they do and do not want to see in a gridview? I would like to have a separate page that holds all of the columns in the database and they can check or uncheck the ones they want.
GaryT
|
|
|
|
|
One way I've done this is by using code to construct the SQL SELECT statement (using only checked columns), then binding that to a gridView with AutoGenerateColumns set to true .
|
|
|
|
|
I actually did it with a btn and a checkBoxList with the event as follows:
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim li As ListItem
For Each li In CheckBoxList2.Items
Select Case li.Value
Case 0
If li.Selected Then
GridView1.Columns(0).Visible = False
Else : GridView1.Columns(0).Visible = True
End If
Case 1
If li.Selected Then
GridView1.Columns(1).Visible = False
Else : GridView1.Columns(1).Visible = True
End If
Case 2
If li.Selected Then
GridView1.Columns(2).Visible = False
Else : GridView1.Columns(2).Visible = True
End If
End Select
Next
End Sub
I am going to update this soon to use a loop to cycle through list items of and columns of unknown amount
|
|
|
|
|
I am working on a project where I would like to be able to search a gridview dataset and return only the results back to the same gridview. I am relatively new to this so your help would be greatly appreciated. This site has already been so much help.
GaryT
|
|
|
|
|
It's the same as loading all the data into it. All you have to do is create a search form on the page with a button. In the button click event, pass the info the user enters in the search form into a function in your data layer which contains a select query/ stored procedure that returns only the results that match. Then bind the returned dataset to your gridview. Something like this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then BindIt()
End Sub
Sub BindIt()
Dim ds As New DataSet
ds = data.GetEverything
If ds.Tables.Count > 0 AndAlso ds.Tables(0).Rows.Count > 0 Then
gdv.DataSource = ds
gdv.DataBind()
End If
End Sub
Protected Sub btnSearchSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearchSubmit.Click
Dim ds As New DataSet
ds = data.GetData(parmaterfromsearchform, another, another)
If ds.Tables.Count > 0 AndAlso ds.Tables(0).Rows.Count > 0 Then
gdv.DataSource = Nothing
gdv.DataSource = ds
gdv.DataBind()
Else
gdv.DataSource = Nothing
gdv.DataBind()
End If
End Sub
-- modified at 18:05 Friday 18th August, 2006
|
|
|
|
|
it looks good except for the:
ds = data.GetData??
What is that?
|
|
|
|
|
"data" is my data layer. This should be in there as a private class variable:
Dim data As New Data
In the example, I have a class named Data that contains all the functions to access data from my database, and each of the functions returns a dataset. You might have a business logic layer in in between your presentation and data layers. For the sample though, I left out the business logic layer and went straight to the data layer.
|
|
|
|
|
I have tried everything to make it work me page minus other code is below.
By the way thank you for your help.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.highlight {text-decoration:none; font-weight:bold; color:black; background:yellow;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="../CPC_Testing/CPCLite_Test.aspx"><b>View Images</b></a>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" AllowPaging="True" AllowSorting="True" CellPadding="1" ForeColor="#333333" GridLines="None" Height="399px" Width="716px" style="table-layout: auto; font-size: x-small; z-index: 100; left: 254px; position: absolute; top: 148px;" AutoGenerateSelectButton="True" DataKeyNames="BegDoc#" BorderStyle="Solid" EmptyDataText="NULL" HorizontalAlign="Center">
<Columns>
<asp:CommandField />
<asp:TemplateField HeaderText="P">
<ItemTemplate>
<asp:CheckBox ID="PrivCheckBox" runat=server />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="C">
<ItemTemplate>
<asp:CheckBox ID="ConfidentialCheckBox" runat=server />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="HC">
<ItemTemplate>
<asp:CheckBox ID="HCCheckBox" runat=server />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="R">
<ItemTemplate>
<asp:CheckBox ID="ResponsiveCheckBox" runat=server />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NR">
<ItemTemplate>
<asp:CheckBox ID="NonResponsiveCheckBox" runat=server />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="BegAttch" HeaderText="BegAttch" />
<asp:BoundField DataField="Folder" HeaderText="Folder" SortExpression="Folder" />
<asp:BoundField DataField="DocDate" HeaderText="DocDate" SortExpression="DocDate" />
<asp:BoundField DataField="DocTitle" HeaderText="DocTitle" SortExpression="DocTitle" />
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:BoundField DataField="Recip" HeaderText="Recip" SortExpression="Recip" />
<asp:BoundField DataField="Copied" HeaderText="Copied" SortExpression="Copied" />
<asp:HyperLinkField DataNavigateUrlFields="BegAttch" DataNavigateUrlFormatString="Default.aspx?BegAttch={0}"
HeaderText="Attach Group" Text="Attach Group" />
<asp:HyperLinkField DataNavigateUrlFields="Source" Text="Download / Open File" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="Aqua" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
<EditRowStyle BackColor="Aqua" BorderStyle="Solid" ForeColor="AliceBlue" />
<SelectedRowStyle BackColor="Yellow" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td colspan="1" style="height: 25px; width: 230px;">
</td>
<td colspan="2" style="height: 25px; text-align: center;">
<strong><span style="font-size: 24pt; text-align: center; border-bottom-width: thick; border-bottom-color: olive; vertical-align: middle; background-color: white;">NetView Case Management</span></strong></td>
</tr>
<tr>
<td colspan="1" style="width: 230px; height: 68px">
</td>
<td colspan="2" style="height: 68px; text-align: center">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal"
Width="57px" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged" style="z-index: 100; left: 14px; position: absolute; top: 73px; vertical-align: middle; overflow: auto; cursor: hand; color: white; background-color: maroon;" Font-Bold="False" Font-Names="Agency FB" Font-Size="7pt">
<asp:ListItem>Folder</asp:ListItem>
<asp:ListItem>DocDate</asp:ListItem>
<asp:ListItem>DocTitle</asp:ListItem>
<asp:ListItem>Author</asp:ListItem>
<asp:ListItem>Recip</asp:ListItem>
<asp:ListItem>Copied</asp:ListItem>
</asp:CheckBoxList>
<asp:Label ID="SortFieldLabel1" runat="server" Text="DocDate" style="z-index: 101; left: 17px; position: absolute; top: 103px" Font-Size="8pt"></asp:Label>
<asp:Button ID="AscDescButton1" runat="server" OnClick="AscDescButton1_Click" Text="Sort" style="z-index: 102; left: 131px; position: absolute; top: 45px" Font-Size="8pt" />
<asp:Label ID="LabelTxt" runat="server" Text="" style="z-index: 101; left: 17px; top: 103px" Font-Size="8pt"></asp:Label>
<asp:TextBox id="keywords" runat="server"/>
<asp:Button id="btnSearchSubmit" Text="Submit" runat="server"/></tr>
<tr>
<td style="width: 230px; height: 398px">
<asp:TreeView ID="TreeView1" runat="server" ImageSet="XPFileExplorer" NodeIndent="15" style="z-index: 100; left: 28px; position: absolute; top: 145px; vertical-align: top;" Height="213px" Width="156px" ShowLines="True">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px"
VerticalPadding="0px" />
<NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" HorizontalPadding="2px"
NodeSpacing="0px" VerticalPadding="2px" />
<Nodes>
<asp:TreeNode Text="All" Value="All">
<asp:TreeNode NavigateUrl="~/CaseSelection/FolderTreeSelection/Priv.aspx" Target="~/CaseSelection/Priv.aspx"
Text="Priviledged" Value="Priviledged">
<asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="Confidential" Value="Confidential">
<asp:TreeNode Text="Resposnive" Value="Resposnive"></asp:TreeNode>
<asp:TreeNode Text="Non-Responsive" Value="Non-Responsive"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="Highly Confidential" Value="Highly Confidential">
<asp:TreeNode Text="Responsive" Value="Responsive"></asp:TreeNode>
<asp:TreeNode Text="Non_Responsive" Value="Non_Responsive"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</td>
<td style="width: 241px; height: 398px">
</td>
<td style="height: 398px">
</td>
</tr>
<tr>
<td colspan="2" style="height: 145px">
<asp:DetailsView DataKeyNames="BegDoc#" ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataSourceID="ObjectDataSource2" Height="50px" Width="666px" style="font-size: x-small; position: relative; left: 0px; top: -13px;" CellPadding="4" ForeColor="#333333" GridLines="None">
<Fields>
<asp:BoundField DataField="BegAttch" HeaderText="BegAttch" SortExpression="BegAttch" />
<asp:BoundField DataField="EndAttch" HeaderText="EndAttch" SortExpression="EndAttch" />
<asp:BoundField DataField="BegDoc#" HeaderText="BegDoc#" SortExpression="BegDoc#" />
<asp:BoundField DataField="EndDoc#" HeaderText="EndDoc#" SortExpression="EndDoc#" />
<asp:BoundField DataField="PgAmt" HeaderText="PgAmt" SortExpression="PgAmt" />
<asp:BoundField DataField="Folder" HeaderText="Folder" SortExpression="Folder" />
<asp:BoundField DataField="DocDate" HeaderText="DocDate" SortExpression="DocDate" />
<asp:BoundField DataField="DocTitle" HeaderText="DocTitle" SortExpression="DocTitle" />
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:BoundField DataField="Recip" HeaderText="Recip" SortExpression="Recip" />
<asp:BoundField DataField="Copied" HeaderText="Copied" SortExpression="Copied" />
<asp:BoundField DataField="Source" HeaderText="Source" SortExpression="Source" />
<asp:BoundField DataField="Attchmt" HeaderText="Attchmt" SortExpression="Attchmt" />
<asp:BoundField DataField="OtherProps" HeaderText="OtherProps" SortExpression="OtherProps" />
<asp:BoundField DataField="ResponsiveTerms" HeaderText="ResponsiveTerms" SortExpression="ResponsiveTerms" />
<asp:HyperLinkField DataNavigateUrlFields="Source" DataNavigateUrlFormatString="CaseView2.aspx?source={0}"
DataTextField="Source" />
</Fields>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataByBegDoc"
TypeName="DataSet1TableAdapters.Boult_DemoTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" DefaultValue="" Name="_BegDoc_" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="BegAttch" Type="String" />
<asp:Parameter Name="EndAttch" Type="String" />
<asp:Parameter Name="_BegDoc_" Type="String" />
<asp:Parameter Name="_EndDoc_" Type="String" />
<asp:Parameter Name="PgAmt" Type="String" />
<asp:Parameter Name="Folder" Type="String" />
<asp:Parameter Name="DocDate" Type="String" />
<asp:Parameter Name="DocTitle" Type="String" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="Recip" Type="String" />
<asp:Parameter Name="Copied" Type="String" />
<asp:Parameter Name="Source" Type="String" />
<asp:Parameter Name="Attchmt" Type="String" />
<asp:Parameter Name="OtherProps" Type="String" />
<asp:Parameter Name="ResponsiveTerms" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
</td>
</tr>
</table>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetDataBy" TypeName="DataSet1TableAdapters.Boult_DemoTableAdapter" InsertMethod="Insert">
<SelectParameters>
<asp:QueryStringParameter Name="SectionName" QueryStringField="CaseName" Type="String" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="BegAttch" Type="String" />
<asp:Parameter Name="EndAttch" Type="String" />
<asp:Parameter Name="_BegDoc_" Type="String" />
<asp:Parameter Name="_EndDoc_" Type="String" />
<asp:Parameter Name="PgAmt" Type="String" />
<asp:Parameter Name="Folder" Type="String" />
<asp:Parameter Name="DocDate" Type="String" />
<asp:Parameter Name="DocTitle" Type="String" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="Recip" Type="String" />
<asp:Parameter Name="Copied" Type="String" />
<asp:Parameter Name="Source" Type="String" />
<asp:Parameter Name="Attchmt" Type="String" />
<asp:Parameter Name="OtherProps" Type="String" />
<asp:Parameter Name="ResponsiveTerms" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
</div>
</form>
<%=Highlight(keywords.Text, LabelTxt.Text)%>
</body>
</html>
-- modified at 11:56 Monday 21st August, 2006
|
|
|
|
|
I'm afraid I won't be able to help any further. You are implementing the objectdatasource control which is a control I'm not familiar with. you may want to take a look at this page[^] which shows a gridview/objectdatasource implementation. I have yet to familiarize myself with it.
|
|
|
|
|
How do I import my previous Microsoft Access database to my new SQL database? I have a feeling I will first have to convert it to some sort of comma deliminated platform and then only somehow get into SQL. Or am I being a moron ... again?
Peace.
--Rory
Every religion's trina tell us that every other religion's going down to hell! -- Rory Lewis 1999
|
|
|
|
|
Have you tried importing data using Import wizard/DTS?
- ashish
|
|
|
|
|
Try this
http://www.microsoft.com/technet/prodtechnol/sql/2000/Deploy/accessmigration.mspx
Ian
|
|
|
|
|
Hello,
I am using following code to call ASP.NET webservicemethod. When I put URL in browser, it works. But when I use MSXML2.XMLHTTP, it fails.
any clues?
CODE:
postUrl = "http://Server/VDir/MyWebService/NewService.asmx/MyMethod"
Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
xmlhttp.Open "POST",postUrl,false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send DataToSend
Response.Write(xmlhttp.responseText)
Appreciate your help
- ashish
|
|
|
|
|
Hi
I hve loaded a data table with values from a database. I want to insert these values into another table in database. How can we insert data directly from datatable into database.
Can anybody help me to solve this problem.
|
|
|
|
|
Are you just moving data from table1 to table2? Are there changes to the data in the datagrid before saving to table2? I'm just trying to figure out why you need the datagrid if you are just migrating data...
|
|
|
|
|
This doesn't have anything to do with ASP.NET. Try the SQL/ADO/ADO.NET forum.
only two letters away from being an asset
|
|
|
|
|
Is it possible to "Enable = false" on all a pages ASP.NET controls with a single command or loop?
As I would like to see if a certain criteria is met (such as being flagged "completed") and if so lock the input controls(which is all controls on that page) from accepting input.
I would like to do this in a fasion whereby I don't have to add every new control added to the page to a big list inside an if statement... if possible.
Thanks.
|
|
|
|
|
Each Page exposes a Controls collection. You could loop over that. e.g.
foreach(Control ctrl in this.Controls)
{
ctrl.Enable = false;
}
|
|
|
|
|
Colin's suggestion is a good one. I'd add another - you could put all your controls inside a Panel object, then set the Panel 's Enabled property to true or false. Something like this:
<%@ Page Language="C#" %>
<script runat="server">
void CheckboxChanged(object o, EventArgs e)
{
panel2.Enabled = Checkbox1.Checked;
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
<asp:CheckBox id="Checkbox1" runat="server"
AutoPostBack="true"
Text="Enable the panel"
OnCheckedChanged="CheckboxChanged"
/>
<br /><br />
<asp:Panel id="panel2" runat="server" enabled="false"
Width="400" BackColor="#EFEFEF"
Style="padding: 4px;"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1">
<asp:TextBox runat="server" text="some textbox" />
<asp:DropDownList runat="server" >
<asp:ListItem text="Item1" />
<asp:ListItem text="Item2" />
<asp:ListItem text="Item3" />
</asp:DropDownList>
<asp:Button runat="server" text="some button" /><br />
</asp:Panel>
</form>
</body>
</html>
|
|
|
|
|
Hello,
When I bind a dataset to GridView (.NET 2.0) which has no record, the GridView control is not visible at that time.
Is there any way where in I can persist the visibility of GridView even in case of no data in dataset?
Regards,
Vipul Mehta
Regards,
Vipul Mehta
Software Engineer
Chenoa Information & Software Services Pvt Ltd
|
|
|
|
|
You can use the EmptyDataText property to set a message that will be displayed.
only two letters away from being an asset
|
|
|
|