move controls and other tools anywhere around the web form and add datagrid list items to a normal list box

how can i place control and other tools anywhere around the page? for some reason i cannot place and move any of my tools and controls anywhere i want them to be. my web form does not look nice. you know like in ms dreamweaver and vb.net, u can place text box,labels etc anywhere on the form, thats exactly what i want to be able to do. also how can i add items from a datagrid list to a normal list box using a button? the datagrid list is data bound. the examples that i have seen so far shows items that are built into the code and then added to the list but nothing for data binded control. any help would be appreciated.

0
misbahmurtza
4/1/2008 12:48:26 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

24 Replies
1924 Views

Similar Articles

[PageSpeed] 41
Get it on Google Play
Get it on Apple App Store

misbahmurtza:
how can i place control and other tools anywhere around the page? for some reason i cannot place and move any of my tools and controls anywhere i want them to be. my web form does not look nice. you know like in ms dreamweaver and vb.net, u can place text box,labels etc anywhere on the form, thats exactly what i want to be able to do.
 

 

Select the Control you want to set. Go to > Layout Menu > Position > Select "Relative" / "Absolute" positioning..

 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/1/2008 1:01:46 PM

Thank you soooooooooooo much. can u also help me with my other datagrid list problem? tnxxx

0
misbahmurtza
4/1/2008 1:23:42 PM

misbahmurtza:
help me with my other datagrid list problem?
 

in your example, that you have seen... you just need to retrive data from database using Select Statement and bind the DataGrid; instead of binding the items that are built in code..

DataGrid1.DataSource = DataSetData;

DataGrid1.DataBind() 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/1/2008 1:51:01 PM

 

this is my button code so far.

 If GridView1.SelectedIndex > -1 Then

ListBox1.Items.Add(GridView1.SelectedValue.ToString)

End If

 so, where abouts do i have to place the code that u gave?

DataGrid1.DataSource = DataSetData;

DataGrid1.DataBind() 

 tnx

0
misbahmurtza
4/1/2008 2:03:41 PM

do i have to declare 'datasetdata'? if so what data type? tnx so far

0
misbahmurtza
4/1/2008 2:07:36 PM

This is the code for the button that is supposed to be adding items from a binded gridview to a normal list box, is this right?

Protected
Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.ClickDim DataSetData As AccessDataSource

GridView1.DataSource = DataSetData

If GridView1.SelectedIndex > -1 Then

ListBox1.Items.Add(GridView1.SelectedValue.ToString)

End If

End Sub

0
misbahmurtza
4/1/2008 2:14:47 PM

 check out the complete code:

ASPX Page: 

 

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField DataField="name" HeaderText="Name" />
                <asp:CommandField ShowSelectButton="True" />
            </Columns>
        </asp:GridView>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox></div>
    </form>
</body>
</html>

  

C#  Code Behind:

 

 

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SqlConnection cn = new SqlConnection(@"data source=XXDATABASESERVERXX;initial catalog=XXDBNAMEXX;integrated security=SSPI");
            cn.Open();
            SqlCommand cmd = new SqlCommand("Select [Name] From [Table1]", cn);
            SqlDataAdapter ad = new SqlDataAdapter(cmd);
            DataSet DataSetData = new DataSet();
            ad.Fill(DataSetData);
            GridView1.DataSource = DataSetData;
            GridView1.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (GridView1.SelectedIndex != -1)
            ListBox1.Items.Add(new ListItem(GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text, GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text));            
    }
}

  

you just need to bind the GridView in Page_Load() event and then you can add the selected value of GridView in ListBox with the code written in Button Click Event...

moreover i suggest you to study Data Controls from below links...it would help you ...

dont forget to mark the answers if it helped you.. thanx
hope it helps./.

 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/2/2008 4:42:53 AM

Hello

 tnx so far.

the above code is in c#, do you know the code in vb? see my vb code in previous posts.

tnx u are very kind to me. i appreciate it.

0
misbahmurtza
4/2/2008 12:18:31 PM

 

what do i have to replace this with : XXDATABASESERVERXX;

                                                               and

                                                   initial catalog=XXDBNAMEXX;

 

my database is a access database not a server database. when i insert this:

SqlConnection cn = new SqlConnection(@"data source=AccessDataSource;initial catalog=Module_SelectionDB;integrated security=SSPI");

i get this error message:

"The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 15:         if (!Page.IsPostBack)
Line 16:         {
Line 17:             SqlConnection cn = new SqlConnection(@"data source=AccessDataSource;initial catalog=Module_SelectionDB;integrated security=SSPI");
Line 18:             cn.Open();
Line 19:             SqlCommand cmd = new SqlCommand("Select [ModuleCode] From [Module]", cn);

"

can you tell me how could correct the above sql connection with access database and can i do all this in vb instead of c#.

0
misbahmurtza
4/2/2008 1:47:46 PM

Code in VB 

 

 

Public Partial Class _Default
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
		If (Not Page.IsPostBack) Then
			Dim cn As SqlConnection = New SqlConnection("data source=XXDATABASESERVERXX;initial catalog=XXDBNAMEXX;integrated security=SSPI")
			cn.Open()
			Dim cmd As SqlCommand = New SqlCommand("Select [Name] From [Table1]", cn)
			Dim ad As SqlDataAdapter = New SqlDataAdapter(cmd)
			Dim DataSetData As DataSet = New DataSet()
			ad.Fill(DataSetData)
			GridView1.DataSource = DataSetData
			GridView1.DataBind()
		End If
	End Sub
	Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
		If GridView1.SelectedIndex <> -1 Then
			ListBox1.Items.Add(New ListItem(GridView1.Rows(GridView1.SelectedIndex).Cells(0).Text, GridView1.Rows(GridView1.SelectedIndex).Cells(0).Text))
		End If
	End Sub
End Class

  

you need to use OLEDb provider for Access Database...

and connection string will be like..

 Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\AccessDB\MyDB.mdb;User Id=admin;Password=;")

 

check out below link for more help on how to connect to Access DB

Connecting to a Microsoft Access database with ASP.NET

 

dont forget to mark all the answers which help you if your problem is solved.. thanx. 

hope it helps./. 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/3/2008 4:22:39 AM

Tnx so far, but for some reason i cannot  get it to work. when i run the project, it highlights the 'ad.fill(dataset)' displaying the error message ' OleDbException was unhandled by the user code'. can i send you a zip file of my project?? how can i send it here.

0
misbahmurtza
4/3/2008 1:27:53 PM

 you can send me along with the access db on kaushal.parik@gmail.com


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/3/2008 1:34:18 PM

Hello kaushal,

 I sent you my project at your address kaushal.parik@gmail.com. please check it and let me know what the problem is with the string connection etc.

thanks!!

0
misbahmurtza
4/4/2008 9:15:26 AM

Hello kaushal,

 please email me regarding this thread, please i need ur help. i am desperate, i have a deadline coming up tnx.

 regards

0
misbahmurtza
4/7/2008 10:31:59 AM

hi misbah,

i did search in my inbox in gmail... but i didn't file any mails from your side...

try another one.. kaushal.parik@hotmail.com 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/9/2008 6:19:01 AM

Hello

i have sent you another email with attachment of my project to the hotmail address.

0
misbahmurtza
4/9/2008 8:41:35 AM

what is the status right now ?

did you visit the below link that i gave you previously... you might be failing with Connection String / Connecting with Access... im giving you the same URL again... give it a try

Connecting to a Microsoft Access database with ASP.NET


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/9/2008 9:57:10 AM

 

Did u send my one of your project to this email address mmisbah911@hotmail.com ?? because i checked my inbox but did not receive an email from u. Did u have a look at my project? did u test it? how can i find out if the connection is made or not?
0
misbahmurtza
4/9/2008 10:34:59 AM

misbahmurtza:
how can i find out if the connection is made or not?
 

i suggest you to first create a simple test application and check that do you able to connect to your Access DB or not... code is given in the link.. 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/9/2008 11:04:58 AM

i created a simple test application and checked to see if i was able to connect to my Access DB, but i am still getting a error.

asp.net highlights 'da.Fill(dt)'  see full code below:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Work\MisbahTest\MyDB.mdb;User Id=admin;Password=;")
        Dim da As New OleDbDataAdapter("select * from Module", cn)
        Dim dt As New DataTable
        da.Fill(dt)  ' this line is highlighted and displays message "Could not find installable ISAM. oledb exception was unhandled by user code.
        da.Dispose()
        cn.Dispose()
        Me.GridView1.DataSource = dt
        Me.GridView1.DataBind()

    End Sub
 
0
misbahmurtza
4/9/2008 2:02:18 PM

misbahmurtza:
this line is highlighted and displays message "Could not find installable ISAM

check out that office is installed on the system where you are trying ?

Could not find installable ISAM Search
 


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/10/2008 5:52:32 AM

Hi misbahmurtza,

Since you are using Access db then use OleDbConnection instead.. see below snippet 

Private Sub BindGrid()
   
    Dim objconn As New OleDbConnection("YOUR CONNECTION STRING")
    objconn.Open()
   
    Dim dt As New DataTable()
   
    Dim sql As String = "SELECT * FROM table1"
    Dim cmd As New OleDbCommand(sql, conn)
    cmd.CommandType = CommandType.Text
    cmd.ExecuteNonQuery()
    Dim ad As New OleDbDataAdapter(cmd)
    ad.Fill(dt)
   
    If dt.Rows.Count > 0 Then
          GridView1.DataSource = dt;

          GridView1.DataBind();
    End If
   
    objconn.Open()
   
End Sub 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then
        BindGrid()
    End If
   
End Sub 

 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
4/10/2008 6:03:42 AM

vinz:

Since you are using Access db then use OleDbConnection instead.. see below snippet 

Private Sub BindGrid()
   
    Dim objconn As New OleDbConnection("YOUR CONNECTION STRING")
    objconn.Open()
   
    Dim dt As New DataTable()
   
    Dim sql As String = "SELECT * FROM table1"
    Dim cmd As New OleDbCommand(sql, conn)
    cmd.CommandType = CommandType.Text
    cmd.ExecuteNonQuery()
    Dim ad As New OleDbDataAdapter(cmd)
    ad.Fill(dt)
   
    If dt.Rows.Count > 0 Then
          GridView1.DataSource = dt;

          GridView1.DataBind();
    End If
   
    objconn.Open()
   
End Sub 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    If Not IsPostBack Then
        BindGrid()
    End If
   
End Sub 

 

pls pls pls READ the question and previous posts first.


Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
0
kaushalparik27
4/10/2008 6:47:38 AM

kaushalparik27 :

pls pls pls READ the question and previous posts first.

I haven't noticed this line below .. :)

da.Fill(dt)  ' this line is highlighted and displays message "Could not find installable ISAM. oledb exception was unhandled by user code.
 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
4/10/2008 7:37:35 AM
Reply:

Similar Artilces:

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form <head runat="server"><script language="javascript" type="text/javascript">   function popWin()   {         var confirmWin = null;      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');   }  </script> &...

how to get the items in a list box when i used jscript to move items from another list box to this list box?
Hello Mate,                   First of all i have 2 list boxes. i am populating the first list box from the database in the load event .and i used jscript to move the items from the first list box to second list box when i click some arrow buttons. now i just want to store the values of the second list box in a datatable and i would like to store that datatable in a session variable.                    If you know any sol...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Move List Box Items to another List Box in VB.net
 Please helping to solve this problem.i need the code in VB.net  Something to get you started: Default.aspx <table border="0"> <tr> <td> <asp:ListBox ID="ListBox1" runat="server" Rows="10" Width="100" SelectionMode="Multiple"> <asp:ListItem>James</asp:ListItem> <asp:ListItem>Kumar</asp:ListItem> <asp:ListItem>Ravi</asp:ListItem> <asp:ListItem>Reshmi</asp:ListItem> <asp:ListItem>Rachel</asp:ListItem> <asp:List...

superreview denied: [Bug 410500] Add "Web form password" description to web form keychain items : [Attachment 295140] fix
Mark Mentovai <mark@moxienet.com> has denied Stuart Morgan <stuart.morgan@alumni.case.edu>'s request for superreview: Bug 410500: Add "Web form password" description to web form keychain items https://bugzilla.mozilla.org/show_bug.cgi?id=410500 Attachment 295140: fix https://bugzilla.mozilla.org/attachment.cgi?id=295140&action=edit ------- Additional Comments from Mark Mentovai <mark@moxienet.com> Not localizable :( ...

superreview requested: [Bug 410500] Add "Web form password" description to web form keychain items : [Attachment 295140] fix
Stuart Morgan <stuart.morgan@alumni.case.edu> has asked Mark Mentovai <mark@moxienet.com> for superreview: Bug 410500: Add "Web form password" description to web form keychain items https://bugzilla.mozilla.org/show_bug.cgi?id=410500 Attachment 295140: fix https://bugzilla.mozilla.org/attachment.cgi?id=295140&action=edit ...

add window form control on web form
i want to add windows from control link label on web from .what should i do?  saurabhiP:i want to add windows from control link label on web from . Windows form controls are for windows application and should not be used on web forms.You want a link label which is the same as a hyperlink in ASP.NET so use that instead.  saurabhiP:i want to add windows from control link label on web from .what should i do?  Hi saurabhiP,Base on my understanding, you want to use windows control to web form. But base on my experience, there are many issues! Check the following l...

Help! How to add a standard web control to a web form?
I have just created a asp.net web application using Visual Studio .NET 2008. I opened the Default.aspx in design view, but I noticed that if I drag any control under the standard control tab to the web form, the cursor changes to the shape ( a circle with a line across to it ) that tells me that I cannot do that.  Why? Did I miss something?  It seems this is the very basic thing people will do. Please help!     It could be because you designer view is out of sync with you source view. Try right clicking into your design and selected 'Refresh...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

how to get the list of all controls used in web form
hi i have a web page with some contorls like table, text box, label, panel etc. when my web page opens i want to know all the controls palced in the web page and their name/id. can any body tell me how to get the control details. thanks durga Every control has a Controls property that returns all the child controls. You can access all the controls on a page by iterating over the Page.Controls property and then these controls' child controls and so on.I could write a signature here, but who'd read it? Hopefully you are using VS, as I do not know how to do this in Web Mat...

Populating and Implementing 4 Dropdown lists on web form through web service
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which contains information About CustomerName, CustomerType, Address, City. These 4 colum values should populate the 4 Dropdown lists. And then I need to implem...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

Web resources about - move controls and other tools anywhere around the web form and add datagrid list items to a normal list box - asp.net.web-forms

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Mt Martha fire under control
A watch and act warning has been issued for Mount Martha and Balcombe after a bushfire threatened homes on Saturday.

Tarago bushfire brought under control
A bushfire which burnt out close to 120 hectares near Tarago on Monday afternoon has been brought under control.

Hyundai recalls Elantra to fix stability control system
Filed under: Recalls , Hyundai , Safety , Sedan , Budget Starting in February Hyundai will recall 155,000 Elantras from the 2011 and 2012 model ...

Using Amazon Echo to control your home? There's a minor change you need to know about
It may be a minority who use the Amazon Echo to control home automation, in fact it likely is. But there are folks who do it, and it can, and ...

I've heard a rumor from Ground Control/Oh no, don't say it's true....
"David Bowie, the infinitely changeable, fiercely forward-looking songwriter... died on Sunday, two days after his 69th birthday...."

Sean Penn Interviews El Chapo for Rolling Stone… SHOCK: Magazine Gives Fugitive Drug Lord Editorial Control ...
Sean Penn interviewed fugitive Mexican drug lord Joaquín Guzmán Loera, known as “El Chapo,” who was captured and returned to prison Friday, for ...

Chipotle Sued For Not Disclosing Food Quality Control Problems To Stockholders
... afternoon . According to Reuters , the lawsuit claims that the burrito chain hurt investors by failing to let them know that “quality controls ...

Is There A Gun Control Issue Chris Christie Hasn't Flip Flopped On?
... while they are campaigning for a higher office, but I'm not sure if I've ever seen a man change his entire position on one issue (gun control) ...

The control quagmire
A desire to limit volatility is giving rise to even bigger risks

Resources last updated: 1/11/2016 4:33:03 PM