|
Hi,
Following on from my other question, I have a GridView which is bound to a SqlDataSource. It has several pages. In my PageLoad() event handler I can get a count of how many pages are on the gridview by the GridView.PageCount property. If that's the case, I'd like to iterate through each page and find a row from the GridView.DataKeys property with a column matching a particular value and select the row.
I've tried iterating through each page by setting the GridView.PageIndex property and then getting the GridView.DataKeys property but the latter isn't updated - it only gets the first (displayed) page's set of values.
|
|
|
|
|
Have you tried looping through the rows after binding.
<br />
GridView1.DataBind()<br />
<br />
For Each row In GridView1.Rows()<br />
'Do whatever<br />
Next <br />
<br />
<div class="ForumSig">Don't you just hate coming up with something to put here?</div>
|
|
|
|
|
Hi
I have a GridView on my ASP.NET 2.0 page which I've populated from a SqlDataSource. It all works great but now I want to use the same page and pass the ID (or primary key value) into the page via a parameter. I want the Gridview to then select the entry with the corresponding ID in the GridView.
In other words, if I open the page without passing a parameter, the gridview shows the data as usual (I've used a select column which highlights the selected row).
If I pass a parameter in, I want the correct page in the GridView to be displayed along with the correct row highlighted.
Is this possible?
Thanks
|
|
|
|
|
Yes, this is possible. I would recommend using a Details View instead of a Grid View, for the simple reason that the Details View is designed to show 1 record whilst the Grid View is for many.
To do this, in the Grid View set the select function to something like Server.Transfer("DetailsViewPage.aspx?ID="+IDFieldFromGridView)
Then in in the Details View page, do:
<br />
If Request.QueryString("ID") = ""<br />
Server.Transfer("GridViewPage.aspx")<br />
End If<br />
<br />
'Pragmatically set params for Details View<br />
Don't you just hate coming up with something to put here?
|
|
|
|
|
I am trying a URL redirection by wrting a code in Application_BeginRequest
in global.asax and using a rule.xml file
Below is the scnerio
#1 user enters a path http://sitename/project/Article06/issue6
This particlar folder "Article06/issue6"is not on the vistual direcory or on website. In Application_BeginRequest i read this path and if the path is equal to Article06/issue6 i redirect him to some other page.
The code works fine when it is executed from visual studio. But when i deploy this in IIS it does'nt even go to Application_BeginRequest method of global.asax it gives me 404 error
Any idea why it is not working on IIS and how can I solve it
Regards,
Pavas
|
|
|
|
|
Sounds like your code is not running, is ASP.NET configured on the machine and the website properly configured ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have noticed that when you enter a path which do not exist on the virtual directory or website. It never comes to Applicaion_BeginRequest method.
Regards,
Pavas
|
|
|
|
|
Are you sure that the file extension you supplied are handled by ASP.NET worker process.
|
|
|
|
|
There was an issue with the IIS and asp.net setup...got it resolved..
sorry for the trouble
Regards,
Pavas
|
|
|
|
|
I wonder if there is an easy way to "extend" the DragPanelExtender in the Ajax Toolbox to carry out one more function. What I want to do is have a postback to the server or send a URL to the server that contains the X & Y position where the DragPanel was dropped.
Essentially what I am trying to to do is allow an ASP.Net panel containing a textbox to be dragged and dropped on one of a dozen or so absolutely positioned images, and the codebehind file to take the appropriate action depending upon the image on which the panel was dropped.
Thought this would be simple, and there are some examples in VS2008 but I am stuck with needing to code this in VS2005
Any sugestions and help would be appreciated
Many Thanks
|
|
|
|
|
Greetings!!!
How do we mimic following ADO Recordset object Property/methods/events in ADO.NET
Requery
Resync
Bookmark
Activeconnection
getBookmark()
setBookmark(currentBM)
Delete ()
close ()
getStatus()
getDataSource()
DataMember()
Update(Fields,Values)
ActiveConnection()
Need urgent HELP!!!!!
Thanks in advance
|
|
|
|
|
Member 4357460 wrote: Need urgent HELP!!!!!
A good first step is to ask in the right forum.
ADO.NET is disconnected, it works differently to ADO.
I'm sure there are books on this, and article, too.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes I agree...with you..
but my current project demands the simulation of ADO Recordset object Property/methods/events in ADO.NET...
I need wrapper class...
thanks
|
|
|
|
|
Why does it require that ? You really can't have it, and because ADO.NET is disconnected, trying to simulate the connectedness of ADO is going to result in a LOT of database traffic.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am trying to come up with a way to use Uri.EscapeDataString() and Uri.UnescapeDataString() in a templated GridView so I can put tags into text that is uploaded into a SQlServer table, so that the formatted text can be put into a label on a web form. By escaping the data, I do not want to have ValidateRequest="false" set on the page header. I am trying to keep sqlInjection attacks from possibly happening on a database editing form.
My goal on this page is to drop one of the html editors onto the page to make the textbox become a word-like editor so the client can format data to be displayed on the website.
Thanks for any suggestions
Tom
|
|
|
|
|
Hi all,
I have this fuction in my class that named Insert:
public void Insert(int Productid, <big>double Price</big>, int Quantity,string Productname, string Productimageurl)<br />
{<br />
int itemindex = itemindexofid(Productid);<br />
<br />
if (itemindex == -1)<br />
{<br />
cartitem newitem = new cartitem();<br />
newitem.Productname = Productname;<br />
newitem.Productid = Productid;<br />
newitem.Quantity = Quantity;<br />
newitem.Price = Price;<br />
newitem.Productimageurl = Productimageurl;<br />
items.Add(newitem);<br />
}<br />
else<br />
{<br />
items[itemindex].Quantity += 1;<br />
}<br />
lastupdate = DateTime.Now;<br />
}
Now i want use this function as bellow:
protected void btnAddToCart_Click(object sender, ImageClickEventArgs e)<br />
{<br />
<big>string Price = double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text).ToString("0.00");</big><br />
string ProductName = ((Label)DataList1.Controls[0].FindControl("Book_NameLabel")).Text;<br />
string PictureURL = ((Label)DataList1.Controls[0].FindControl("picLabel")).Text;<br />
int ProductID = Convert.ToInt32(Request.QueryString["idLabel"]);<br />
if (Profile.cart == null)<br />
{<br />
Profile.cart = new ShopCart.wroxshoppingcart();<br />
}<br />
Profile.cart.Insert(ProductID, Price,1,ProductName,PictureURL);<br />
Server.Transfer("ItemIndex.aspx"); <br />
}
I have problem with Price,i convert price to string ,then i want send price that be converted to string to function, that the type of price in my function is double.
How i can do this work?
thank you
Hoda
|
|
|
|
|
Why did you convert it to string in the first place?
You can replace this line:
string Price = double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text).ToString("0.00");
with this:
double Price = double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text);
|
|
|
|
|
To build a little on hspc reply
double d = 0;
bool DoubleParseSuccessful;
try
{
DoubleParseSuccessful = double.TryParse(double.Parse(((Label)DataList1.Controls[0].FindControl("PriceLabel")).Text).ToString("0.00"), out d);
}
catch (FormatException Fex)
{
DoubleParseSuccessful = false;
}
if (DoubleParseSuccesful == false)
{
}
This will prevent your application from crashing if someone posts false data back to the server by changing the PriceLabel.
|
|
|
|
|
Why not just call tryparse, and not bother with converting back and forth ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
...<br />
Profile.cart.Insert(ProductID, Convert.ToDouble(Price),1,ProductName,PictureURL);<br />
...
I Love T-SQL
Don't torture yourself,let the life to do it for you.
|
|
|
|
|
Thank you very much for your responses
Hoda
|
|
|
|
|
I am trying to create an advanced treeview control that has some added control features. My problem is that the treeview does not display. I can add other controls such as a textbox and it displays with out any problems, so I'm assuming it has something to do with the treeview control itself. Here is the code I'm using.
After some further testing I have noticed that the problem is not in the rendering but with in VS2008. I can not edit the nodes within VS2008. It tells me that the object is null. So that is where the probem is.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AdvancedWebTreeView
{
[ToolboxData("<{0}:AdvancedWebTreeView runat=server></{0}:AdvancedWebTreeView>")]
public class AdvancedWebTreeView : Panel
{
public AdvancedWebTreeView()
{
if (ViewState["AdvancedTreeView"] == null)
{
p_AdvancedTreeView = new TreeView();
p_AdvancedTreeView.Attributes.CssStyle[HtmlTextWriterStyle.Position] = "absolute";
p_AdvancedTreeView.Attributes.CssStyle[HtmlTextWriterStyle.Top] = "0px";
p_AdvancedTreeView.Attributes.CssStyle[HtmlTextWriterStyle.Left] = "0px";
p_AdvancedTreeView.Attributes.CssStyle[HtmlTextWriterStyle.Height] = "100px";
p_AdvancedTreeView.Attributes.CssStyle[HtmlTextWriterStyle.Width] = "100px";
ViewState["AdvancedTreeView"] = p_AdvancedTreeView;
this.Controls.Add(p_AdvancedTreeView);
}
else
{
p_AdvancedTreeView = (TreeView)ViewState["AdvancedTreeView"];
this.Controls.Add(p_AdvancedTreeView);
}
}
private TreeView p_AdvancedTreeView;
[Category("Internal Controls")]
public TreeView AdvancedTreeView
{
get
{
return p_AdvancedTreeView;
}
}
protected override void RenderContents(HtmlTextWriter output)
{
this.CreateChildControls();
this.RenderChildren(output);
}
}
}
modified on Saturday, May 3, 2008 3:02 PM
|
|
|
|
|
The following example demonstrates how to use the Row property to access the properties of the data row during the ItemCreated event.
<br />
<br />
<![CDATA[<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default6.aspx.vb" Inherits="Default6" %>]]><br />
<br />
<![CDATA[<br />
<br />
<script runat="server"><br />
<br />
Sub EmployeeFormView_ItemCreated(ByVal sender As Object, ByVal e As EventArgs)<br />
<br />
Dim row As FormViewRow = EmployeeFormView.Row<br />
<br />
Dim rowView As DataRowView = CType(EmployeeFormView.DataItem, DataRowView)<br />
<br />
row.ToolTip = rowView("FirstName").ToString() & " " & _<br />
rowView("LastName").ToString()<br />
<br />
End Sub<br />
<br />
</script><br />
<br />
<html><br />
<body><br />
<form id="Form1" runat="server"><br />
<br />
<h3>FormView Row Example</h3><br />
<br />
<asp:formview id="EmployeeFormView"><br />
datasourceid="EmployeeSource"<br />
allowpaging="True"<br />
datakeynames="EmployeeID"<br />
onitemcreated="EmployeeFormView_ItemCreated" <br />
runat="server"><br />
<br />
<itemtemplate><br />
<br />
<table><br />
<tr><br />
<td><br />
<asp:image id="EmployeeImage"><br />
imageurl='<%# Eval("PhotoPath") %>'<br />
alternatetext='<%# Eval("LastName") %>' <br />
runat="server"/><br />
</asp:image></td><br />
<td><br />
<h3><![CDATA[ <%# Eval("LastName") %></h3> <br />
<%# Eval("Title") %> <br />
</td><br />
</tr><br />
</table><br />
<br />
</itemtemplate><br />
<br />
</asp:formview><br />
<br />
<br />
<br />
<br />
<br />
<asp:sqldatasource id="EmployeeSource"><br />
selectcommand="SELECT [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] FROM [Employees]"<br />
connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>" <br />
runat="server"/><br />
<br />
</asp:sqldatasource></form><br />
</body><br />
</html><br />
<br />
<br />
but when i run it an exception accured Object reference not set to an instance of an object.
i don't know what is problem
thanks
|
|
|
|
|
Do you have northwind set up ? Does that code point to the right connection string on your PC ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Do you have northwind set up ? Does that code point to the right connection string on your PC ?
yes i have it on my local SqlServer but whenever i run this sample an exception occured
|
|
|
|