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:
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 |
![]() |
Thank you soooooooooooo much. can u also help me with my other datagrid list problem? tnxxx
![]() |
0 |
![]() |
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 |
![]() |
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 |
![]() |
do i have to declare 'datasetdata'? if so what data type? tnx so far
![]() |
0 |
![]() |
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 AccessDataSourceGridView1.DataSource = DataSetData
If GridView1.SelectedIndex > -1 ThenListBox1.Items.Add(GridView1.SelectedValue.ToString)
End If End Sub
![]() |
0 |
![]() |
dont forget to mark the answers if it helped you.. thanxcheck 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 ...
![]() |
0 |
![]() |
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 |
![]() |
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:
|
"
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
Hello
i have sent you another email with attachment of my project to the hotmail address.
![]() |
0 |
![]() |
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 |
![]() |
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:
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 |
![]() |
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:
this line is highlighted and displays message "Could not find installable ISAMcheck 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 |
![]() |
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 SubProtected 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:
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 SubProtected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
BindGrid()
End If
End Subpls 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 :
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 |
![]() |