|
yes my code is inside if (!IsPostBack) block..
but evrytime i click say page 2 the screen goes blank.
|
|
|
|
|
I can't reproduce this behaviour. When paging through the Grid the screen doesn't go blank. Im using VS 2010.
Maybe it has something to do with the data source you've bound to the control?
|
|
|
|
|
my datasource is a list of objects returned from the service.
Since I need to format it before displaying I convert it into a datatable and this datatable is datasource to the grid. I have stepped thru and found that datatable has populated fine with all the values. even the page comes up fine with all the data and 123 page links down. it's when i click page 2/3 link in pager that it goes blank. am using vs 2008 .net 3.5
|
|
|
|
|
You should probably separate all the three subroutines. Have the !(PagePostback), datagrid itself, and the Grid1_PageIndexChanging all separate and not in one sub.
|
|
|
|
|
my page load checks if it's not postback it calls the gridview load which does what i've posted and i have seperate event handler.
|
|
|
|
|
I had the same issue. I had to literally re-bind the entire datagrid for it to work. It worked for me, and was working under time cruch, I stuck with it.
|
|
|
|
|
what do u mean by rebind, rewrite the code?
|
|
|
|
|
Hi ,
Your Page_Load checks if it is not a postback right ?
This means your code sets the DataSource property of your grid ONLY once and that is when the page loads for the first time.
Please write the code "grid.DataSource = dataTable;" just before the code "grid.DataBind()" and let me know if it works.
Always make it a habit to set the DataSource of a grid just before calling the DataBind() method on the grid.
E.g. I would always code method like "BindPersonsData()" in my application which would be like -
private void BindPersonsData()
{
grdPersons.DataSource = GetPersons();
grdPersons.DataBind();
}
private DataTable GetPersons()
{
DataTable dt = new DataTable();
//logic to get data
return dt;
}
-------------
Ankur - The Tech Anky
Think Simple, Code Simple, Do Big
|
|
|
|
|
copy this aspx.cs page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BIndgrid();
}
}
void BIndgrid()
{
grid1.Enabled = true;
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("ID");
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
grid1.DataSource = dt;
grid1.DataBind();
}
protected void grid1_PageIndexChanged(Object sender, GridViewPageEventArgs e)
{
grid1.PageIndex = e.NewPageIndex;
grid1.DataBind();
BIndgrid();
}
}
|
|
|
|
|
Super.
Thanks Sneha Bisht
|
|
|
|
|
Hi,
how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year .
I want get the information to update on it .
thanks .
|
|
|
|
|
Is it stored in the database as a DateTime? If so then you get the same way you would get any other column. Once you have the DateTime object you use the properties the structure, Day, Month, Year to get the constituent parts.
In these situations I usually rely on a little trick I like to refer to as Reading the Documentation, or as some abbreviate it, RTFM
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Why you aren't using Calendar1 control?
If you have to split birthday value in controls then use Year,Month,Day SQL Functions.
e.g
select year(birthday) from mytable
select month(birthday) from mytable
select day(birthday) from mytable
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
no I don't need to use the calender but I need only return birthdate from database into variable as DateTime and then spilt it into day to put it in the dropdownlist , month into another dropdownlist , year into textbox to update information about user .
|
|
|
|
|
So, you can bind dropdowlists and textbox with query which I wrote you in previous post.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
So you want to use three query, with all the overhead, to return one value, DateTime, which already has the properties for Day, Month, Year. Even if you combined into one query it is still unnecessary to separate the values in the SQL statement.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
That was only example about Year,Month,Day SQL functions.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year .
I want get the information to update on it .
for that task
first you have to create two dropdownlist for day and month and fill them.
then try this code
void BIndBirthDay()
{
DateTime _bdate = DateTime.Now; -- get this date from database field
int day = _bdate.Day; -- return int value(find day of datetime field like that)
drp_day.SelectedIndex = -1;
drp_day.Items.FindByValue(Convert.ToString(day)).Selected = true; -- bind that perticulare day to dropdownlist by that
}
hope this helps and also same down for month (_bdate.Day) and year (_bdate.Year)
|
|
|
|
|
Yes, that's really what I want
thank you very much
|
|
|
|
|
HELLO EVERYONE
first.. i have a database...
dbName: Database
tblName: tblUser
FieldNames: UserID, UserPassword, UserType
example:
alc14647, 12345, admin
bti12345, 67890, user
ggt09876, 45673, editor
blah blah blah
my question is... how do i enabled or hide ex.[buttons or lables]
if the user type is logged in?
i have a SEPARATE LOG IN PAGE, and a MASTER PAGE for my layout and the other page is selected MASTER PAGE for the CONTENTS
ex. admin can see or enable to use a certain buttons or lables
and the user can only use or see a specific labels or buttons after log in,
my buttons or labels are
LABEL1
LABEL2
LABEL3
LABEL4
LABEL5
LABEL6
LABEL7
LABEL8
LABEL9
all the labels can see the ADMIN in the MASTER PAGE note[that labels is isn't the ContentPageHolder, i put it in the OUTSIDE]
and the other user can SEE that labels on their SPECIFIC type,
this my CODE for my SEPARATED Log in page and it's in the same project located also[hope you'v gonna get it^_^]
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim cn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dr As OleDbDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
txtUsername.Focus()
Label1.Text = ""
Try
With cn
If .State = Data.ConnectionState.Open Then .Close()
.ConnectionString = "Provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\database.mdb")
.Open()
End With
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUsername.Text = "" Or txtPassword.Text = "" Then Exit Sub
With cmd
.CommandText = "Select * from tbluser Where userid = '" & Trim(txtUsername.Text) & "' and passid = '" Trim(txtPassword.Text) &"' "
.Connection = cn
dr = .ExecuteReader
End With
If dr.HasRows Then
Session("name") = txtUsername.Text 'it will display o the other page, it depends
Response.Redirect("Main.aspx") 'my main.aspx is connected to my MASTER PAGE and all the other page
Else
Label1.Text = ("ERROR! " & txtUsername.Text)
End If
End Sub
End Class
what code i'm gonna suppose to do? and where i'm gonna put it??
please.. i need some help...
just to enabled, disabled, visible = TRUE or FALSE the specific ITEM like BUTTONS and LABELS that depends on the USERTYPE...
thank for READING i hope READER's can HELP ME..
THANKS in ADVANCE ^_^
modified on Wednesday, May 4, 2011 10:26 AM
|
|
|
|
|
Already you have asked this question[^] in Q/A section. Also John answered...please wait for some time you can get other replies too.
|
|
|
|
|
Adding to above, can you unbold please! It's hard to radread as such (and looks odd!)
|
|
|
|
|
S Mewara wrote: hard to rad
Yes, rapid application development can be hard.
|
|
|
|
|
Thanks. Corrected it.
|
|
|
|
|
hi.......
i am currently in final year of diploma and i want to develop an video chat application in asp.net....
can anyone help me please??
|
|
|
|