|
Get the items in a datatable. Maintain a counter variable to count the previous and next clicks. According to the counter variable display values from datatable. Keep datatable in one session or cache.
|
|
|
|
|
Suppose you have the required records in a datatable dt, you only need to iterate the row index keeping the column index constant.
The rows index value needs to be stored into a hidden field after each iteration. Below is the C# code for the default.aspx for displaying the records.
<br />
using System;<br />
using System.Data;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
<br />
public partial class _Default : System.Web.UI.Page <br />
{<br />
Cls_DBtier Cls_DBtierobj = new Cls_DBtier();<br />
int i = 0;<br />
DataTable dt;<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
<br />
Cls_DBtierobj.mvar_DBConnectionstring = Application["Connection_String"].ToString();<br />
Cls_DBtierobj.OpenConnection();<br />
dt = Cls_DBtierobj.getNames();<br />
i = dt.Rows.Count;<br />
Cls_DBtierobj.CloseConnection();<br />
LblNames.Text = dt.Rows[0][0].ToString();<br />
<br />
}<br />
protected void BtnNxt_Click(object sender, EventArgs e)<br />
{<br />
int index = Convert.ToInt32(HidIndex.Value);<br />
if (index < i-1)<br />
{<br />
index = index + 1;<br />
HidIndex.Value = index.ToString();<br />
LblNames.Text = dt.Rows[index][0].ToString();<br />
}<br />
}<br />
}<br />
HidIndex is the hidden field, LblNames is the label for displaying the records. And BtnNxt is the button display the next record.
Cls_DBtier is class file. Below is the code for it.
<br />
using System;<br />
using System.Data;<br />
using System.Data.SqlClient;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
<br />
public class Cls_DBtier<br />
{<br />
public string mvar_DBConnectionstring;<br />
SqlConnection conn;<br />
public void OpenConnection()<br />
{<br />
conn = new SqlConnection(mvar_DBConnectionstring);<br />
}<br />
public void CloseConnection()<br />
{<br />
conn.Close();<br />
}<br />
public SqlCommand ReturnSqlCommand(string sqlStmt)<br />
{<br />
SqlCommand Cmd;<br />
try<br />
{<br />
Cmd = new SqlCommand();<br />
Cmd.Connection = conn;<br />
Cmd.CommandType = CommandType.Text;<br />
Cmd.CommandText = sqlStmt;<br />
return Cmd;<br />
}<br />
finally<br />
{<br />
Cmd = null;<br />
}<br />
}<br />
public DataTable getNames()<br />
{<br />
string stt = "SELECT ename FROM employee";<br />
SqlDataAdapter SAdaptor;<br />
SqlCommand Cmd;<br />
DataSet ds=new DataSet();<br />
DataTable dt;<br />
try<br />
{<br />
Cmd=ReturnSqlCommand(stt);<br />
SAdaptor = new SqlDataAdapter(Cmd);<br />
SAdaptor.Fill(ds);<br />
dt = ds.Tables[0];<br />
return dt;<br />
}<br />
finally<br />
{<br />
stt = null;<br />
SAdaptor = null;<br />
Cmd = null;<br />
ds = null;<br />
dt = null;<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hi,
Myself Smruti pursuing mca
n facing problem while doing my project the data access from table to dropdown list
can anyone solve my problem by sending me the code
smruti
|
|
|
|
|
Smruti,
Did you populate the required data from the database to a datasource i.e. dataset, datareader, datatable etc...
assuming you used a dataset with the data then you have to give the following code for filling the dropdownlist
dropdownlistid.datasource = datasetname;
dropdownlistid.datatextfiled = datasetname.tables[0].Columns["ColumnName"]
dropdownlistid.datavaluefield = datasetname.tables[0].Columns["ColumnName"]
Doing so the drop down list would be populated with text and respective values.
Gautham
|
|
|
|
|
use this in code behind
I am taking All the districts in a DataSet and binding to a drop down list
DataSet result = null;<br />
<br />
<br />
result = userBll.GetKommunes();<br />
<br />
cbKommune.Items.Clear();<br />
cbKommune.DataSource = result;<br />
cbKommune.DataTextField = "KOMMUNE_NAVN";<br />
cbKommune.DataValueField = "KOMMUNE_NR";<br />
cbKommune.DataBind();<br />
cbKommune.Items.Insert(0,new ListItem(captions.GetString("PleaseSelectKommune"),"0"));
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
Hi,
I'm using a gridview control. It has a checkbox template field with an OnCheckedChanged event. How do I access row number in gridview
inside OnCheckedChanged event of my checkbox?
Thanks!!!
-- modified at 6:55 Wednesday 16th May, 2007
Gerri
|
|
|
|
|
Hi
Are you calling a Javascript method from code behind for the event OnCheckedChangedEvent? So you might have attached the event in run time.. Right ???
Pass ClientID of the field Checkbox as a parameter to the calling method. Then using that parameter you can easily locate a row of GridView
Hope this helps.
Harini
|
|
|
|
|
|
Hi All,
I am using ASP.NET 2.0. I am using iFrame in my project which has 4 parts and one of them contains tree view and others are header, footer and view dynamic pages on tree view node click. All I need to hidden treeview to view my dynamic page in full screen.
Please help me...
Thanks in advance.
|
|
|
|
|
I am new for ASP.NET
I had developed an leave application, for a company.
Now i have to deploy it, so i made a installer with setup wizard, but i dont know how to specify the URL to call the application at the server once installed.
Can any one tell me how to do it? (OR)
Is there any other way to deploy the application(Simple or Complex)
-------------------------------
And what are the requirements at the server to install the application. I had installed .NET framework and IIS 6.0
Is there any thing else and Should i have to configure any thing at the server.
Can any one plese help me with the process.
Plz.... Help
Jats
|
|
|
|
|
Once you install the application via set make sure that you have a web share created for that folder. Once that is done you can use the share name to launch the application
You can very well do an XCopy create a web share and launch the application from that sharename.
|
|
|
|
|
Can you tell me how can i create a web share for it.
I have no idea.
Jats
|
|
|
|
|
Select the folder right click go to sharing and do the required ...
|
|
|
|
|
After installing the application.
How can i call it in my browser(Client browser).
Jats
|
|
|
|
|
Hi Friends,
How to integrate Limelight Server with ASP.NET. Limelight Server is a Server which stores multimedia contents such as Video and Audio files
Can anyone give me suitable link or advice on Limelight Server and its integration with ASP.NET application.
|
|
|
|
|
Hello;
how can I filter filediolog to show only Images for example..
using asp.net
tkml123
|
|
|
|
|
I never find an option to do this in web
|
|
|
|
|
me tooo ,anybody who how to do that,,,
or saw in any website
tkml123
|
|
|
|
|
Its not possible, you have no control over the browser's file dialogue.
|
|
|
|
|
True enough... you cannot filter on the client side, you would have to do it on the server side, or use a third party control.
There is one called NeatUpload[^], which is free, that has this functionality built into it (I think)...
hth,
~dnc
|
|
|
|
|
Hi there,
Is there anyone who can guide me to creating ActiveX controls that can be installed and run in browsers like IE7.0
I'm talking about something like Microsoft Update via Internet Explorer where it requires you to install some sort of ActiveX control in order to proceed and download the updates.
I'm trying to create client-side control in a similar fashion but using not COM/C++ way, but to use C# or VB.NET to create it and particularly run on ASP.NET 2.0 web applications.
Thanks
|
|
|
|
|
ActiveX controls are created the same way they have been for years, either in C++, VB6, or .Net with some heavy-duty com/com+ work going on in the background. IE7 CAN install and use ActiveX controls, but with the amount of havoc they can wreak on a user's system, why bother? Not to mention all the hell of getting it signed, and then hopefully bypassing the end-users security enough to even get it installed (I know people who run IE in high security mode... NOTHING runs on their machines... Except .Net applications )
you might want to look at WinForms in IE[^]
(a quick search in Google yeilds tons of results)...
This would be a MUCH better approach than having to go anywhere close to ActiveX controls (IMHO)
HTH,
~dnc
|
|
|
|
|
I am using ajaxtoolkit:tabcontainer in a user control. using two tab panels.
How can i get the values of the textbox while saving for the selected tab?
ascx page
---------
<ajaxToolkit:TabContainer ID="ajTabContainer" runat="server" OnActiveTabChanged="ajTabContainer_ActiveTabChanged">
<ajaxToolkit:TabPanel ID="group" runat="server" HeaderText="Group" >
<ContentTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Group</td>
<td><asp:TextBox ID="txtGroup" runat="server"></asp:TextBox></td>
</tr>
</table>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="code" runat="server" HeaderText="Code">
<ContentTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Code</td>
<td><asp:TextBox ID="txtCode" runat="server"></asp:TextBox></td>
</tr>
</table>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
<asp:Button ID="btnsave" runat="server" OnClick="btnsave_Click" />
Sandeep Kumbhar
|
|
|
|
|
I have created this nice website using Dreamweaver + some DHTMl plugins.But the plugins are free and not registered.So, creating the expandable menus was nice and easy except for that the menus dont give you working links to other pages.
You can create but they will not work, maybe its coz the DHTML is not registered.The links are disabled.Where can I find such a software dat will give me working links????
function switchUrl (nmenu, url, trgFrame)
{
if (trgFrame == "_self")
trgFrame = null;
var mt=url.indexOf("mailto:");
if(mt!=-1)window.top.location=url.substring(mt);
else
{
var find=url.indexOf("javascript:");
if (find!=-1)
{
eval(url.substring(find));
}
else
{
if(trgFrame)
{
if (trgFrame=="_blank") window.open (url);
else if (trgFrame=="_top") window.top.location.href=url;
else if (trgFrame=="_parent") parent.location.href=url;
else
{
var fr=findFr(window.top,trgFrame);
if(fr)fr.location.href=url;
else window.location.href=url;
}
}
else
{
nmenu.targetFrame.location=url;
}
}
}
}
function onItemClick()
{
var item=this;
var close=true;
var nmenu=eval ("window."+item.nmenuId);
var url = item.url;
if (url)
{
kagiso
|
|
|
|
|