|
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
|
|
|
|
|
Hi,
I'm having a rather curious problem. I have a GridView (ASP.NET 2.0) that has 3 image fields (commands.) One of those fields deletes the row.
First, the command name was "delete" and so I used the GridView1_RowDeleting event method. I put the code to delete the row from the database there. Then, I changed the command name to "del" and used the GridView1_RowCommand method to catch the command and perform the deletion.
Now, after deleting the row, I would like to reload the updated table from the database and bind it again with the gridview. So I use this:
<br />
GridView1.DataSource = sessionParams.SiteDS.Tables["Users"];<br />
GridView1.DataBind();<br />
sessionParams is a class holding all the Session variables amd SiteDS is the dataset holding the tables of the website.
Now the problem: whenever I click to delete, the row after it also gets deleted, and if it's the last row I get an exception that the index is not valid. That's because the delete command is fired twice, the first time the correct row gets deleted and then for some weird reason, the event is fired again and the row after it gets deleted (since it has the same index now.)
What I noticed afterwards was that this only happens when I use the code that i mentioned above. That is, if I don't do the databind thing, only one row is deleted. However, in this case, the gridview is not updated
So, what is the problem here? Why is the event fired twice?
Thanks.
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Where do you put your sample code to rebind the GridView control? Have you tried it in the PreRender event?
|
|
|
|
|
Hi,
The binding code is in a method that is called from the RowCommand or the RowDeleting click event method. If I put the binding code in the PreRender method, wouldn't it be executed before control passes to the event methods?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
There is something I noticed that is worth mentioning.
This double event firing only occurs when the ButtonField of the GridView is an Image. I have another GridView with ButtonFields shown as links and the event is fired once.
Weird?!?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi,
I am using asp.net 2.0. In this,i am using Cross Page Posting. From the second page, i am trying to reference a control (Label) in the prevoius page using 'PreviousPage' property.
Here, in the first page, that Label control is placed within the "asp:Content" tag. (ie I am using MasterPage's ContentPlaceHolder).
Page.PreviousPage.FindControl("lebelid") method return null.
In case of normal page ( without Masterpage), it works fine. Can anyone help me in this? Thanks in advance.
Regards,
Jay
|
|
|
|
|
Because the Label is placed in the Content control, that also means it is later put in the ContentPlaceHolder control which is a naming container. So you need to get reference to this control fist before accessing the Label control.
|
|
|
|