|
Hello,
I have an asp.net35 vb page which gets a list of users from the database, displays them in a gridview and also has a couple of input boxes and a submit button so that I can use it to send a group email.
Each process works separately. I can see my gridview list and the email form works if I dont call in the gridview rows.
I have hit a problem that I hope you can help me with. The error says:
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection
This is my line of code:
email = GridView1.DataKeys(gvRow.RowIndex).Value
Can anyone help me to solve this please.
|
|
|
|
|
I think there could be a clue in the error message. It suggests that the rowindex is outside the key collection. Maybe looping zero to gvrow.rows.count rather than count -1 (as you start at zero)?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hello Bob,
I found that I could get at the index using this code on page load. It outputs numbers starting at 1. Your snippet cant be used in the context of datakeys so Im still stuck.
For Each gvRow In GridView1.Rows
'display the row index number for testing.
Labeltestrows.Text &= gvRow.Cells(0).Text "
Next
|
|
|
|
|
Hi,
I'm developing a web page - asp.net ( .net 3.5 - visual studio 2008 ) :
This is my idea :
I need to add Controls to a web form page programmatically (labels, textboxes, ect..)
Controls must be grouped into "Sections".
I Inserted a Multiview onto my page.
When I load the page, I retrieve information about controls in a database.
Then I create a view and add it to multiview control and so add controls to each view.
Now I want display my "sections" like tab strips :
My code (more or less) :
protected void Page_PreInit(Object sender, EventArgs e)
{
if (!IsPostBack)
{
ChargeControls();
this.MultiViewSections.ActiveViewIndex = 0;
}
}
private void ChargeControls()
{
read database table
for each record
(example)
...
viewSection = new View();
viewSection.ID = "Section" ;
int indexSection = 0 ;
...
label = new Label();
label.ID = "lblSection" ;
label.Text = "text Section";
this.MultiViewSections.Views[indexSection].Controls.Add(label);
...
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:MultiView ID="MultiViewSections" runat="server">
</asp:MultiView>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Default.aspx">Home
page</asp:HyperLink>
</form>
</body>
</html>
I can see first view
( this.MultiViewSections.ActiveViewIndex = 0; ).
But I can't navigate to others views , I get this error :
ActiveViewIndex is being set to '0'. It must be smaller than the current number of View
controls '0'.
For dynamically added views, make sure they are added before or in Page_PreInit event.
Parameter name: value
I inserted two buttons onto the page and I try to use these instructions :
NextView/PrevView , SwitchViewByID, MultiView1.ActiveViewIndex += 1 / -= 1 .
No result!
what's wrong ?
Thanks in advance .
p.s.
A MultiView control is a good choice in this situation ?
|
|
|
|
|
You basic issues are that your controls will not have viewstate unless they are added prior to Page Load, and that you need to store things like your active index in viewstate for them to survive the postback and be restored.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
in dropdownlist client side ie in onchange iam writting function with a confirmation .if the confirmation is true go to server side code for this iam writting return true else iam giving return false .but my problem is that for return false also the page is getting postback and getting server side is executed.how to stop the execution of server side in the return false .
|
|
|
|
|
Have you set AutoPostback = False for the control?
Remember too that users may disable javascript in theor browser, so you shouldn't rely on that alone...
|
|
|
|
|
Hi Any one.
I use a httpmodule for urlRewriting in my web site.
At local i use a "SimpleRewriter" class in App_code and Set
Webconfig as here:
add name="SimpleRewriter" type="SimpleRewriter, App_Code"
But When i Upload my site on server it doesn't work and give Some Error as "Page Requested not found".
I think on server asp.net doesn't have reach to my module and cant access it.
Any help?
Thanks.
sepel
modified on Friday, November 28, 2008 9:02 AM
|
|
|
|
|
Hi sepel,
I am facing the same problem.
Did you able to resolve this problem.
If yes, then please send me the details of the same.
Thanks in advance.
Regards
Vinit
ok
|
|
|
|
|
Hi.
I resolve my problem.
Set your http module in webserver section for iis7.
sepel
|
|
|
|
|
Hi
Thanks for your reply.
I made the following changes in the web.config file
configuration
system.webserver
modules
add name="CustomModule" type="Samples.CustomModule"
modules
system.webserver
configuration
But it still not working. Can you please provide your settings for this?
Regards
Vinit
ok
modified on Monday, December 8, 2008 9:23 AM
|
|
|
|
|
Put your urlRewriter class in App_code folder.
And put these line in your module section of webserver section:
<remove name="Session">
<add name="Session" type="System.Web.SessionState.SessionStateModule">
If it still don't work send me error and your code.
sepel
|
|
|
|
|
Hi
Thanks for your reply.
I put the urlRewriter class in App_code folder as per your suggestion.
I made following changes in the web.config file.
system.webServer
modules
add name="HttpErrorHandler" type="AssemblyName.HttpErrorHandler" precondition="managedHandler"
modules
system.webServer
The error was occured as
HTTP 404 - File not found
Internet Information Services
Thanks.
ok
|
|
|
|
|
|
Yes, I set it in the web.config.
My local IIS version is 5.1.
thanks
ok
|
|
|
|
|
Hi,
Can anyone recommend me a book to read about the use of IIS with asp.net, and how they interact with each other. Thanks
hawari
hawari
|
|
|
|
|
|
Hi,
Which one is done before, publishing the database or copy website, is copy website alone enough to complete the deployment?
regards,
hawari
|
|
|
|
|
Thoguh main objective are same for those, there are hugh different between copy web sites and Publish. Those are used to based on specific situations.
Please Read This Article[^]
This is clear your doubts.
ahawari09 wrote: is copy website alone enough to complete the deployment?
Yes !! It can !!! But based on situation.
cheers,
Abhijit
|
|
|
|
|
|
i m new to asp .net i have a gridview bind to a session["total"] there is one grandtotal field and one link button. on the link button clientclick a new pop window appear where data is bind to datalist . check box is for to select in which text box he want to enter data i want these total he enter in any number of text box back into the first from which this popwindow was called and add these total to grandtotal of that row .
i m also sending the id as a querystring
amirzada
|
|
|
|
|
Then, What is your problem ?
cheers,
Abhijit
|
|
|
|
|
i want these total values the one enter in the text box and display it in the parent page.....
i don't have any idea how to access a spesific page as here is the parent page.
amirzada
|
|
|
|
|
use
var txt.value=window.opener.formName.ControlId
Like this
|
|
|
|
|
I was using sql server 2005 on my asp.net application and everything was going right , until i installed sql server 2008 ( both express edition ) , and now i get
Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).
my connection string is
<add name="SQLManageStationsConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SQLManageStations.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
is it about the system.data.dll or something ? what can i do ?
|
|
|
|