|
|
Hi I want to do paging in the datalist.
For that i wrote the code:
public int intStart=0;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
ViewState ["Start"]= 0;
list();
}
}
public void list()
{
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter("select name from sampledatagrid",conn);
DataSet ds1 = new DataSet();
intStart = (int) ViewState["Start"];
ViewState ["PageSize"]=7;
sda.Fill(ds1,intStart,(int)ViewState["PageSize"],"sampledatagrid");
dlistSample.DataSource=ds1.Tables[0].DefaultView;
dlistSample.DataBind();
conn.Close();
}
private void lnkPrevious_Click(object sender, System.EventArgs e)
{
intStart = (int) ViewState["Start"] -(int) ViewState["pageSize"];
ViewState["Start"] = intStart;
if (intStart <= 0 )
{
ViewState["Start"] = 0;
}
list();
}
private void lnkNext_Click(object sender, System.EventArgs e)
{
int dlistcount = dlistSample.Items.Count;
intStart = (int)ViewState["Start"] + (int)ViewState["pageSize"];
ViewState["Start"] = intStart;
if ( dlistcount < (int)ViewState["pageSize"] )
{
ViewState["Start"] = (int)ViewState["Start"] - (int)ViewState["pageSize"];
}
list();
}
}
Here the values are displayed correctly in the Datalist., But If i cliks the Next or previus linkbutton(<< or >>) at the time it shows the error:
Object reference not set to an instance of an object.
Error occured in this line:
intStart = (int)ViewState["Start"] + (int)ViewState["pageSize"];
How can we solve this one?
Prabu.T
|
|
|
|
|
on the pageindexchanged event of the datagrid write this code.
DataGrid.CurrentPageIndex = e.NewPageIndex;
after this line call the datagrid to load the contents again
this will work fine.
Vipin
|
|
|
|
|
How do i display the contents dynamically on the right pane of the IE by clicking on a link in tree view? tell me how do i create frames?
|
|
|
|
|
Hi,
BharadwajN wrote: tell me how do i create frames?
You can insert the Frame Set from Visual Studio, directly. Then set the pages to be displayed in the frames.
<marquee>"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
Hi,
How I can get the server side control : radio buttonlist's selected value through javascript.I want to get the selected value on each item selection without posting back..
please show me the right way.
Thanks,
RPM
SoftwareDeveloper(.NET)
|
|
|
|
|
one way could be that onclick of the radio button you iterate through all the elements and then get the value of the element which is checked.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
Thanks much for the reply..Can I get some cod snippet..
Thanks RPM,
SoftwareDeveloper(.NET)
|
|
|
|
|
Hi,
I have a load button which will call a method called btmExport_Click when itz clicked..
Its working fine but my problem is this event is called twice. (ie) after click and again on page load...how can i detach this event on page load(after click)to avoid firing that event again
I am not explicitly calling that function in page load
Regards,
Sivaprasad
|
|
|
|
|
have you checked the ispostback in the load event?
Best Regards,
Apurva Kaushal
|
|
|
|
|
YES i HAVE CHECKED AND MORE OVER I AM NOT CALLING THIS FUNCTION(btn_Export_Click)) ON PAGE LOAD
Regards,
Sivaprasad
|
|
|
|
|
Make sure that autoeventwireup attribute of page directive is set to false
|
|
|
|
|
AutoEventWireUp of the page directive is alreddy set to false..still...
still my issue is not solved
Regards,
Sivaprasad
|
|
|
|
|
|
Hai,
I have a webuser control enriched with some web server controls.In a web form,I have to refer the properties of the controls of webuser control.While I am referring those properties, an error is raising as
'<usercontrolname>.protected dim with events <controlname> as system.web.ui.webcontrols.textbox' is not accessible in this context because it is 'protected'.
Where can I declare the control as public in a web application? and how we can do that?
Any suggestions......please welcome...
-Priya
|
|
|
|
|
U can Refer the controls in the usercontrol
by ((controltype)Page.FindControl("controlId")
((Button)Page.FindControl("btnxxx"))
Regards,
Sivaprasad
|
|
|
|
|
Thanq, but I need to refer the controls of web user control in some other .aspx page. Using Page.FindControl() , we can refer the control in the same page.But, how can we refer it at some other web form?
-Priya
|
|
|
|
|
If you want to use the controls of the usercontrol(ascx file), then you have to make them public.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Thanq, can u please tell where we can make the controls as public in asp.net 2.0 so that we can use them anywhere in the project???
-Priya
|
|
|
|
|
I haven't worked on 2.0 but you can make them public where they have been declared.
Best Regards,
Apurva Kaushal
|
|
|
|
|
In 1.1, we can view the designer generated code for a web form. But, for 2.0, I didn't find anywhere such automatic generated code for the control declarations.I am new to the 2.0. Anyway, thanks Kaushal.
-Priya
|
|
|
|
|
|
Make a public method in the user control that will modifiy the controls you wish modified.
|
|
|
|
|
I have used the BulletedList control and the output of hyperlinks is in this manner because simple I have put the text value "Create Account - Create user account for login" etc.
Create Account - Create user account for login
Login - Login to your account.
Is it possible to use the bulletedlist and display in this format. Such that only the Create Account is underline (link). Which property at the bulletedlist could help?
Create Account - Create user account for login
Login - Login to your account. Hurry!
If not is there any way such that I can write a simple introduction just next to the hyperlinks with a bulleted list.
thanks in advance. Much appreciated.
|
|
|
|
|
yes what you need to do is to make that button runat=server and give an id.
Best Regards,
Apurva Kaushal
|
|
|
|