|
Good morning experts,
How can I get the total number of rows in a gridview that has paging and a filter.
ex.
dw.RowFilter = strFilter 'dw is a dataview
GridView1.DataSource = dw
GridView1.DataBind()
gridview1.Rows.Count gives me the number of records in the current page
dw.Table.Rows.Count gives me the number of all records ignoring the filter.
Thanks
|
|
|
|
|
Use dw.Count instead of dw.Table.Rows.Count
when you use the Table property of the dw DataView you're referencing the original table and not the DataView itself
Greets! Joel
|
|
|
|
|
|
No problem
Greets! Joel
|
|
|
|
|
HI
I am having problems with the below code, it creates a user within my usertable, and validates that passwords match, but i can't get it to provide the user with a confirmation page this is the code I have.
I get the error message error executing child request for userHome
Sub send_loginCreds(ByVal sender As Object, ByVal e As EventArgs)
Dim litErr As New LiteralControl
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; uid=; pwd=o;database=ftp1;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
Try
'Set command string to equal SPROC
cmdString.CommandText = "sp_myInsertusers"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As New MySqlParameter
param = cmdString.Parameters.Add("?p_username", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("?p_password", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtPassword.Text
param = cmdString.Parameters.Add("?p_firstname", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtFirstName.Text
param = cmdString.Parameters.Add("?p_lastname", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtLastName.Text
param = cmdString.Parameters.Add("?p_phone", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtPhone.Text
param = cmdString.Parameters.Add("?p_mail", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = txtMail.Text
'Executes stored procedure
connection.Open()
cmdString.ExecuteNonQuery()
connection.Close()
Server.Transfer("userHome")
Catch ex As Exception
'Returns error message
litErr.Text = ex.Message
MsgBox(ex.Message)
End Try
|
|
|
|
|
Is userHome an *.aspx page, try using
Server.Transfer("userHome.aspx")
One advice(not related to your problem but related to your code) is to leave your connection string in the web.config and accessing it from there, that way you don't have to have the connection string in every single DB access method
Greets! Joel
|
|
|
|
|
me stupid
cheers joel
|
|
|
|
|
The basic purpose:
I code the Form for changing Profile Properties.
The basic Problem:
When i change web.config (adding or removing new Properties)
how to make changes to Form what i write.
Tried to use ObjectDataSource but there the delirium turned out...
Now as though I write Buisness Class which thought to connect to ObjectDataSource and to change through FormView.
But I do not know how many properties it profile and I can not to everyone make Class properties. Pleace help... Throw ideas as it
|
|
|
|
|
I am really confused with this issue. I have a datagrid where I am creating columns dynamically. Everything gone fine till page posts back. It failed to maintain the state of the grid. I tried with enabling view state for the grid, but no use! What is happening ? Is ASP.NET having any problem on keeping the data for dynamically created columns ?
|
|
|
|
|
Yeah. That's why we used to do like that
Page_load(){<br />
if(!IsPostBack){<br />
DataSet ds = Database.GetDataMethod();<br />
datagrid.DataSource = ds.Table[0];<br />
datagrid.DataBind();<br />
Cache["mydata"] = ds.Table[0];<br />
}<br />
else{<br />
datagrid.DataSource = Cache["mydata"];<br />
datagrid.DataBind(); <br />
}<br />
}
|
|
|
|
|
Thanks for your suggestion Michael, But assume that I have some textboxes in these dynamically created columns. I won't be able to access the textbox value because of this problem. Your code caches the datatable and binds it again, but what about the values changed in text boxes ? I think I won't be able to get it
|
|
|
|
|
Yeah. I think so.. One way I can think of is that you hav to save those values in somewhere (eg: cache) before postback and set it back accordingly onload. it's not flexible solution....
|
|
|
|
|
Michael Sync wrote: I can think of is that you hav to save those values in somewhere (eg: cache) before postback and set it back accordingly
That is fine. But what will happen if I change the control value before posting back ? This method will assign previous value to the controls.. I think this is a bug in ASP.NET. What do you think ?
|
|
|
|
|
Why create dynamic columns?
You can use template columns and create a template containing multiple web server controls to manage the the dynamic presentation of content which will have their state maintained, and can also utilise the RowDataBound event to manipulate row level content if you have a need to go that far.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
Rhys666 wrote: You can use template columns and create a template containing multiple web server controls to manage the the dynamic presentation of content which will have their state maintained,
Thanks, But I won't be able to do this, because I can't predefine the number of columns that I have on the grid. So how do I implement this method. One question, If I place a contentplaceholder inside template columns or added controls dynamically to the template columns, will it maintain the state ?
|
|
|
|
|
Navaneeth. wrote: Thanks, But I won't be able to do this, because I can't predefine the number of columns that I have on the grid
Why? I've got to be honest and say I can't really see where you're trying to go with this, as a developer surely you know have some awareness of the base objects you're dealing with. It just appears you're trying to be too generic in your approach and it'll probably mean more work and far less re-usability in the long run. Can you explain why you need an almost entirely dynamic DataGrid/GridView?
I'd assume that as per dynamic controls on a page what you need to do is recreate your dynamic columns and their controls on every postback and if that doesn't work, what you're attempting probably isn't supported.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
Hi,
i know the month .
From this how i find the number of days in that month
All I ever wanted is what others have.... CrazySanker
|
|
|
|
|
DateTime.DaysInMonth ?
Christian Graus - Microsoft MVP - C++
"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 got it..
int iNoDay=System.DateTime.DaysInMonth(EntTransactionDate.Year, EntTransactionDate.Month);
thank u
All I ever wanted is what others have.... CrazySanker
|
|
|
|
|
Hi..
I want to clear the Text of a label Control Before Redericting the page to another page.How should i do it in .Net 2003
I am clearing the Text of the Label in a Button Click event and then I am Redericting the Page
But it is not working. I am Expecting a reply
Thanks
Mahesh.J
|
|
|
|
|
Mahesh.J wrote: I am Expecting a reply
I bet you are...
What do you want to do ? Your button click event will fire on the server side, and the page with the label cleared will not be rendered, because you will redirect before that can happen. Why do you need to clear it first ? It's lost anyhow.... To do this so the user sees it clear, you'd need to use javascript.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
hai all,
i would like to know how to use web services..can any one help with
good example or goos link... thanks in advance
with Regards,
Imthiyas Ahamed.A
|
|
|
|
|
www.google.com ?
Seriously, there's a lot of reading on offer, and your question is far too vague for a decent response. Do you know what a web service is, or did you just hear the terminology somewhere ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
hai,
i know the concept of webservice.. but still i have not applied in projects..
with Regards,
Imthiyas Ahamed.A
|
|
|
|
|
Get it[^]
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|