|
Hi all,
My apologies if this is an easy one (v.new to this!) but I get the following error when clicking edit a datagrid with a dropdownlist.
'System.IndexOutOfRangeException: StatusID'
In my datagrid I'm calling functions in VB. One to get the status and populate a Dataset & one to get selected index so I can set the initial value of the dropdownlist.
I then have the update sub to declare the dropdownlist and and update the database.
Would anyone be able to point me in the right direction?
Many Thanks
Rob
|
|
|
|
|
Is status ID a valid identifier for the drop down list's selected index property?
Do you really want the selected rows index?
If possible could you post the code so I can see what you are doing please?
Dan
|
|
|
|
|
Hi Dan, thanks for the reply.
Here is my code showing functions to populate the dataset and to get the selected row.
StatusID is the primary key in my access database & thought I'd need to use it to default the value of the dropdownlist to the current value.
Function GetStatus() as DataSet
Dim DBConn as OleDbConnection
Dim DBCommand as OleDbDataAdapter
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("data/Auto_log.mdb") & ";")
DBCommand = New OleDbDataAdapter("SELECT StatusID, Status from Status ORDER BY Status", DBConn)
DBCommand.Fill(DS, "Status")
DBConn.Close()
Return DS
End Function
Function GetSelectedIndex(ByVal StatusID As String) As Integer
'Loop through the DataSet DS
Dim iLoop As Integer
Dim DT As DataTable = DS.Tables("Status")
For iLoop = 0 To DT.Rows.Count - 1
If StatusID = DT.Rows(iLoop)("StatusID").ToString Then
Return iLoop
End If
Next iLoop
End Function
I then declare the ddl in my update subroutine as follows
Dim ddlStatus As DropDownList = FindControl("ddlStatusctrl")
and here is the ddl control from my datagrid:
<asp:TemplateColumn>
<HeaderTemplate>
Status
</HeaderTemplate>
<ItemTemplate>
<%# Container.DataItem("Status") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id="ddlStatusctrl" runat="server"
DataTextField="Status"
DataValueField="StatusID"
DataSource="<%# GetStatus() %>"
SelectedIndex='<%# GetSelectedIndex(Container.DataItem("StatusID")) %>' />
</EditItemTemplate>
</asp:TemplateColumn>
Rob
|
|
|
|
|
Did anybody know how to help others , may be students, developers, through coding,may be ASP.Net, C#.Net And
have some earning from that. If anybody knows, plz tell me the website or any resource through which i can do that.
Bijay Bhaskar Deo
Thanks & Regard
|
|
|
|
|
|
i am using sessions but it is not deleting the user from database when the user click the browsers 'x' close button.
|
|
|
|
|
Ok try as how bijay said.
Regards,
Satips.
|
|
|
|
|
how to delete a user from database when user click on the browser close button in asp.net
subbarao.k
|
|
|
|
|
What let hte question be specific.
I could not able to get you ?
If the user closes the window the user has to be deleted from the database.
Regards,
Satips.
|
|
|
|
|
i am creating chatroom for that if user by mistake click the close button of the browser instead of clicking the signout, then he must delete from the database plz help me
subbarao
|
|
|
|
|
You can try this with Session. If the Browser closes the close button it will get deleted.
Regards,
Satips.
|
|
|
|
|
When user closes the browwer window the onunload event fires of the body element. Use a function to handle the event raised and in the function send an asynchronous request to the browser using XMLHTTP object and delete the data from the database.
Bijay Bhaskar
Bijay Bhaskar Deo
Thanks & Regard
|
|
|
|
|
send me the code for this please
|
|
|
|
|
or you can hook on the onunload event of the window browser...
<< >>
|
|
|
|
|
hi, Bhaskar if we use onunload event it will fire for every refresh of the page i tried of it also but....
|
|
|
|
|
plz suggest me to disable the close button of the browser
|
|
|
|
|
Try with the Javascript
function winClose()
{
if (confirm("Are you sure you want to navigate away from this page?"))
{
window.close();
}
return false;
}
Then put the following code in the body tag:
Hope this will help you.
Regards,
Satips.
|
|
|
|
|
i am dealing with database how it will work with the javascript
|
|
|
|
|
you can use AJAX concept
<< >>
|
|
|
|
|
Try with Atlas
Regards,
Satips.
|
|
|
|
|
Do one thing- use both onload and onunload event with handler. both the events are fired when the page is loaded , but only onunload event is fired when the page is closed. Use this technique to apply ur logic to segregate a refresh from closing window. Fine
Bijay Bhaskar
Bijay Bhaskar Deo
Thanks & Regard
|
|
|
|
|
When i am using onunload event that is if any response is coming from server it is firing
else
suggest me how to disable the close button of the browser so that he will use only signout buttuon
|
|
|
|
|
your chat page get refreshed entirely??? why dont you put into an iframe...??
<< >>
|
|
|
|
|
Use window.onunload instead of the body events.
SG
|
|
|
|
|
As per our requirement i have created a word report with password.
And i am exporting it to the client system.
It works fine in some system. But in some client system the gif images are not correctly loaded.
For all the clients the images are correctly generated at the server(i commented the code of deleting the file at the server).
And it also happened that for some clients where the images were not correctly loaded it began to load when tried another day. And vice versa also happened yet another day. I really don't know why this inconsistancy is happening.
And i was checking out at the clients were Word 2000 was installed. As i was automating Word 2000(Word 9.0.2720) at the server.
Actually while creating the document at the server i am inserting a table containing those gif images, with some formatted headings in it...
And that table is made as a header for the word document...
I am just not able to figure out...what could be the problem ?
I have synchronized that thread so that at any point of time only one process can access it...
As
// Declared an object exclusively declared for synchronization as a member
// variable as i am calling GC.Collect();
private Object objLock = new Object();
// And inside the method
lock(objLock)
{
// Code which has to be executed synchronously
}
as per the link
Please help...
Or is there any settings to be set in the word at the client, so that ".gif" images can be imported.
And is there any way to enforce that settings while exporting the file to the client... Doubtful of that, as we will have to
change settings of the Word Application at client...but still...
Hope some body can throw some light...
Please help...It is really getting late for me...
I have no idea why it is behaving like this...
-- modified at 23:43 Thursday 10th May, 2007
O
|
|
|
|