Click here to Skip to main content
15,888,000 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: how i get the html page in the iframe using java script(its urgent plz help me) Pin
jagan1235-Nov-07 18:59
jagan1235-Nov-07 18:59 
QuestionAn application that will get the updates from server automatically Pin
payback5-Nov-07 17:21
payback5-Nov-07 17:21 
AnswerRe: An application that will get the updates from server automatically Pin
Christian Graus5-Nov-07 17:31
protectorChristian Graus5-Nov-07 17:31 
QuestionProduce Graph Pin
solarthur015-Nov-07 15:06
solarthur015-Nov-07 15:06 
AnswerRe: Produce Graph Pin
Christian Graus5-Nov-07 15:41
protectorChristian Graus5-Nov-07 15:41 
GeneralRe: Produce Graph Pin
solarthur016-Nov-07 2:50
solarthur016-Nov-07 2:50 
QuestionFormatting Gridview Pin
simsen5-Nov-07 11:05
simsen5-Nov-07 11:05 
QuestionGridview delete giving "Specified argument was out of the range of valid values" exception Pin
AdamMcKee5-Nov-07 10:46
AdamMcKee5-Nov-07 10:46 
Three days and 100 google searches later and I still can't find any resolution to this Gridview problem I'm having.

I've got a Gridview that is tied to a Sqldatasource. The delete command for the Sqldatasource is:

DeleteCommand="UPDATE tblIPAddress SET SubnetID = 0 WHERE SubnetID = @SubnetID;DELETE FROM tblSubnet WHERE SubnetID = @SubnetID"For reference, "SubnetID" in "tblIPAddress" is an integer field that allows nulls. It's not a primary key. The command executes smoothly (at least it appears to)- the correct record is deleted from "tblSubnet" and all appropriate records in "tblIPAddress" have their SubnetID value set to "0".

However... after the row is deleted from the Gridview, an exception is thrown:

"Specified argument was out of the range of valid values. Parameter name: value"

And a stack trace of:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value]
System.Web.UI.WebControls.GridView.set_SelectedIndex(Int32 value) +1500503
System.Web.UI.WebControls.GridView.HandleDeleteCallback(Int32 affectedRows, Exception ex) +354
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +123
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +927
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1155
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +199
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


From what little I can read of the stack trace, it would appear that the Gridview is having problems setting its SelectedIndex, but I've tried setting the SelectedIndex of the gridview to everything under the sun and nothing seems to make any difference. I've tried setting it to 0, -1, null (which doesn't work anyway), etc. I've tried setting it in the PageLoad even (using IsPostBack), the Gridview's row deleted event, row deleting, updated, updating, you name it.

The -one- thing I found on Google was someone mentioning that turning on paging in the gridview seemed to stop the problem. Oddly enough, it does. I enabled paging, set the page count to something really high so that more than one page is never created, and voila, the error goes away. That's a sloppy fix, though.

I've also found that adding GridView1.SelectedIndex = -1; AND GridView1.DataBind(); to the RowDeleted event of the Gridview causes the error NOT to be thrown if there's only one record in the Gridview and I delete it. If there's more than one record, the error gets thrown every time until there's only one record in the GridView.

Does anyone have any idea what could be going on here?

Thanks in advance.

AnswerRe: Gridview delete giving "Specified argument was out of the range of valid values" exception Pin
Imran Khan Pathan5-Nov-07 18:36
Imran Khan Pathan5-Nov-07 18:36 
AnswerRe: Gridview delete giving "Specified argument was out of the range of valid values" exception Pin
krubin925-Jun-10 12:46
krubin925-Jun-10 12:46 
QuestionHow i can import tables from another DB ? Pin
sofy20085-Nov-07 10:32
sofy20085-Nov-07 10:32 
AnswerRe: How i can import tables from another DB ? Pin
Colin Angus Mackay5-Nov-07 11:07
Colin Angus Mackay5-Nov-07 11:07 
GeneralRe: How i can import tables from another DB ? Pin
sofy20086-Nov-07 23:32
sofy20086-Nov-07 23:32 
QuestionPopulating Hidden Fields Pin
ffowler5-Nov-07 7:37
ffowler5-Nov-07 7:37 
AnswerRe: Populating Hidden Fields Pin
Christian Graus5-Nov-07 8:12
protectorChristian Graus5-Nov-07 8:12 
GeneralRe: Populating Hidden Fields Pin
ffowler5-Nov-07 8:41
ffowler5-Nov-07 8:41 
GeneralRe: Populating Hidden Fields Pin
Christian Graus5-Nov-07 8:50
protectorChristian Graus5-Nov-07 8:50 
GeneralRe: Populating Hidden Fields Pin
ffowler5-Nov-07 8:52
ffowler5-Nov-07 8:52 
GeneralRe: Populating Hidden Fields Pin
Christian Graus5-Nov-07 8:59
protectorChristian Graus5-Nov-07 8:59 
Questionhow can emulate button click in a site in my ASP.NET code? Pin
B.A5-Nov-07 7:04
B.A5-Nov-07 7:04 
AnswerRe: how can emulate button click in a site in my ASP.NET code? Pin
Christian Graus5-Nov-07 8:54
protectorChristian Graus5-Nov-07 8:54 
GeneralRe: how can emulate button click in a site in my ASP.NET code? Pin
B.A5-Nov-07 9:31
B.A5-Nov-07 9:31 
Questionreload page after filewatcher event Pin
Barbarus5-Nov-07 5:57
Barbarus5-Nov-07 5:57 
AnswerRe: reload page after filewatcher event Pin
Pete O'Hanlon7-Nov-07 1:58
mvePete O'Hanlon7-Nov-07 1:58 
Questionjavascript for Random images pick Pin
sivaram praveen5-Nov-07 5:36
sivaram praveen5-Nov-07 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.