|
Hi,
I am having a problem of getting the primary key or the id of the table I retrieve from the database in the Grid View so that I can delete it. So far I could get the index of the table such as which row I'd selected but it is not the primary key in my database.
Would need some help here, thanks.
J Liang
|
|
|
|
|
U can use the DataKeyNames of GridView to do this.When u write a query then take primary Key also with and store it in DataKyeNames.
Hope this helps u...
|
|
|
|
|
Hi,
I'm not sure how this DataKeyNames work but my code is like this.
For index As Integer = 0 To Me.gvStaff.Rows.Count - 1
Dim cb As CheckBox = CType(Me.gvStaff.Rows(index).FindControl("ckCheck"), CheckBox)
If cb.Checked Then
'I was trying to use the label to check whether it actually grab the value
Me.Label1.Text = Me.gvStaff.DataKeyNames.GetValue(0) 'Not sure it can work like this
End If
Next
J Liang
|
|
|
|
|
Do like this:
strval(0) = "ID"
strSql = "Your Query"
oDS = ObjDB.ExecuteDataSet(strSql) ' Execute your query which return dataset.
GridView1.DataSource = oDS
GridView1.DataKeyNames = strval
GridView1.DataBind()
On Row Command do this:
Dim oGridViewRow As GridViewRow
oGridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)
objLoanPayOff.LoanPayOffID = CInt(GridViewLoanPayOff.DataKeys(oGridViewRow.RowIndex).Value)
If e.CommandName = "DeleteTrans" Then
With objLoanPayOff
.ID = objLoanPayOff.LoanPayOffID
.UserId = CLng(Session("UserId"))
.FormId = msForm_TYPE.msForm_LOANPAYOFF
End With
objLoanPayOff.DeleteRecord()
errormsg.Text = const_MESSAGE_DELETE_RECORD
BindGridView()
ElseIf e.CommandName = "Edit" Then
Response.Redirect("frmLoanPayOffView.aspx?id=" & objLoanPayOff.LoanPayOffID & "&info=" & e.CommandName)
End If
Hope this help u...
|
|
|
|
|
Do like this:
strval(0) = "ID"
strSql = "Your Query"
oDS = ObjDB.ExecuteDataSet(strSql) ' Execute your query which return dataset.
GridView1.DataSource = oDS
GridView1.DataKeyNames = strval
GridView1.DataBind()
On Row Command do this:
Dim oGridViewRow As GridViewRow
oGridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)
objLoanPayOff.LoanPayOffID = CInt(GridViewLoanPayOff.DataKeys(oGridViewRow.RowIndex).Value)
If e.CommandName = "DeleteTrans" Then
With objLoanPayOff
.ID = objLoanPayOff.LoanPayOffID
.UserId = CLng(Session("UserId"))
.FormId = msForm_TYPE.msForm_LOANPAYOFF
End With
objLoanPayOff.DeleteRecord()
BindGridView()
ElseIf e.CommandName = "Edit" Then
Response.Redirect("frmLoanPayOffView.aspx?id=" & objLoanPayOff.LoanPayOffID & "&info=" & e.CommandName)
End If
Hope this help u...
|
|
|
|
|
Hi,
Thanks for the code, but what I did was I drag and drop the grid view from the Database Explorer, therefore I have none of those coding above that I can actually 'view' it physically.
The code I show you runs when I click on the delete button. Is there another way of getting the ID? As I tried to get part of your code into mine, I got this error
System.InvalidCastException: Unable to cast object of type 'ASP.staff_list_aspx' to type 'System.Web.UI.WebControls.GridViewRow'
from
oGridViewRow = CType(CType(Me.gvStaff, Control).NamingContainer, GridViewRow)
J Liang
|
|
|
|
|
Hi,
I have a login page where I type user name and passwordn text boxes and it matches the password with th database and three failed attempts it locks the user account and after that even the user try with his valid password it wouldn't allow the user to login in. My question is how can I lock the user account after three failed attempts.
|
|
|
|
|
erm.... your database is only good for storing data and providing views of it. Your code is free to do whatever it likes with this data, these are your business rules. So, you need a flag in the DB to tell you a members status, and if they are locked out, then you return a result to indicate this, and the UI shows them that this is their current state, so they can do something about it
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
How would I pass the values from a webpage to a modal popup. Right now I am doing like this. I am calling the modalpopup from the javascript function using window.openModalDialog() function. And in the popup webform I am setting the parameters to the hidden variables in the onload event of the body. once I load the parameters I am again calling the pageload manually by doing __doPostBack. The problem with this is the page is posting back twice(one initially and the other manually).
Following is the initialization method of the onload event.
function init()
{
var params = window.dialogArguments();
if(params != null)
{
document.getElementById('hiddenVar1').value = params[0];
document.getElementById('hiddenVar2').value = params[1];
...
__doPostBack('', '');
}
}
Since it is doing the postback twice it is hurting the performance. Please let me know if there is a better way to call the popups?
Thanks,
sridhar.
|
|
|
|
|
Doesn't that function take a URL ? Can't you pass params on the URL ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I can pass params on the url. But the problem is with security. The user can easily change the parameters and get different data. That is why I am not passing parameters as a query string.
Thanks,
sridhar.
|
|
|
|
|
your page should, no matter what, do a security check before showing any data.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All,
I have one confusion regarding the webservices.
Suppose I made one webMethod in webservices .
Then how can I make this webMethod as secure one.
i.e If somebody come to know about the URL then can easily use this web Method.So how can I make sure that only the Authenticate person is using the webSevices Method.
IF anyBody has the idea please share it.
Thanks
Rahul
|
|
|
|
|
You can make your methods take a username/password. I'm not sure if you can check the calling IP address, and decide based on location. The Microsoft Web Service Extensions have other security features, also.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
In windows C# programing there is the ability to create C# windows projects like in SharpDevelop[^]. Is there anything like this that people could use on the internet? What I would like to do is allow people to access a SharpDevelop[^] kind of web page that users can create and change items on a web editor.
NOTE: I am not looking for an html web editor. I am looking for visual studio editor but web based.
Chris
|
|
|
|
|
Data driven development?
What kind of scalability?
|
|
|
|
|
I wouldn't say it is data driven....more like object driven. Were a user can drag and drop objects onto a designer and resize objects and configure an objects properties. Something like that.
|
|
|
|
|
maybe something like tibet from www.technicalpursuit.com.
or maybe one of those OS sites like gh.os.t or bobel or something like that.
|
|
|
|
|
I'm sure if it existed, we would have heard of it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have created a webpage which contains two gridviews. The first gridview contains the list of orders made a company. The second gridview displays the details of the order. I also have a dropdownlist so that they can select particular year and view the list of orders for that year. The user can click on individual orders in the left side grid and it will display the order details on the right side grid. I am using callbacks to display the details. If I didn't select any year and it is defaulted to all the years, the performance of the page is really slow. If I select a particular year and click on orders the performance is better. So I thought that if we didn't select any year the view state will be big(that is why the performance is slow) and if we select particular year the viewstate will be less(better performance). But when I checked the viewstate in both the cases it is same. It has same number of characters. So I am not sure which is hurting the performance. Please let me know your views.
Thanks,
sridhar.
|
|
|
|
|
D.Sridhar wrote: So I am not sure which is hurting the performance.
How about:
* The amount of data the query returns to the browser.
* The length of time it takes to perform the query that returns the larger result set.
* The amount of additional disk access the unfiltered query needs to retrieve the data.
|
|
|
|
|
Hi,
When I run the query in the QueryAnalyzer it returns the data instant. And the amount of data is the same for all the requests. What I didn't understand is the following...
If I select the year (2007) in the dropdownlist then the number of orders for that year is around 12. so the left side grid which is the list of orders has 12 records and the right side grid has the details for the last order for that year. And when I click on another order on the left side grid, it returns the details in 1 or 2 seconds. But I didn't select the year and if the left side grid has like 1000 records, it is taking like 6 - 10 seconds. The number of records in the details grid will be exactly same. I thought that it might be with the viewstate. But I read that callbacks doesn't update viewstate. so I am not understanding why there is a performance difference. Am I missing something?
Please let me know.
Thanks,
sridhar.
|
|
|
|
|
Are you using AJAX, or are you using ATLAS to gain AJAX ? ATLAS does a full postback of your entire page. It's not very efficient.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am using Microsoft ASP.NET AJAX 1.0
|
|
|
|
|
OK, they call it that now, do they ? That would be ATLAS then.
It's more efficient to write your own code, although if you tinker with ATLAS, I think you can make it run better than the default ( which involves a full page lifecycle for any AJAX call )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|