On my Home page I have a gridview that has Four columns: CustomerID, Product, Quantity, then a link (which appears on each row..called View). When a user clicks View on a particular row it will then send that particular CustomerID to the next page (CustomerProfile.aspx).
On the CustomerProfile.aspx page I have a textbox where the Customer Name should appear. How do I go about displaying the customer name in the textbox based on the CustomerID passed to the customerprofile.aspx page? Do I need to call a stored procedure? Do i need to call the Customer Table in my code?
(i'm using C#) Thanks!! Ur help is very much appreciated!How do I display data in a textbox based on an ID passed from 1st page?
In PHP it would be: $_SESSION['CustomerID']
--------
Sorry, didn't see that part the first time thru. You would need to pull from your database table. Sounds like you know what you're doing, but it would be something like this (again in PHP):
$query = ';SELECT Customer_Name FROM TableName WHERE CustomerID=CustomerID';;
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$customer = $row['CustomerID'];
how to gridview
Wednesday, August 18, 2010
VISUAL WEB DEVELOPER, NEED HELP!!!?
for the past 2 years I have been working with Visual Basic 6 and have gotten pretty used to it. Problem is, now I have to get to know Visual Web Developer because I need to make a program that can use the internet as well. This means I have a short time to get used to it and need help.
How do I show results from one table in an MS Access Database but using primary keys?
e.g. if I have 2 tables (X %26amp; Y) how do I use one Field in table X to return results from table Y. I am using an ASP GridView and a Drop Down box to do it but if there is abetter way then so be it.VISUAL WEB DEVELOPER, NEED HELP!!!?
Create view using SQL (http://www.w3schools.com/sql/default.asp鈥?/a>
Want to set the column names of the data grid with numerical values?
I'm just trying to view the contents of my table in a grid view control and the contents of the control will vary from time to time. So I tried to bind the data in run time with the grid view..
now the problem which I'm facing is, some of the columns in the table are named as m1,m2,m3.. Now I want to display the column names in the user interface or grid as 1,2,3..so on up to the number of columns does the grid view have..
like I have a table in database as with the column names as
sno name reg no m1 m2 m3 ............mn
now I want to display them as
sno name regno 1 2 3 ..........n
how is it possible if we are binding the gridview with the table at runtime
hope I have done with my explanation.. I would expect the result as early as possible...
thanks in advance
--radhaWant to set the column names of the data grid with numerical values?
If its just the matter of displaying different name of the column in the grid then you can set header text of column of grid at run time with code , I am not sure with syntax. Use msdn for best
Visual Basic help!?
I have a bit of a problem with Visual Basic here. I'm basically working with a database that displays bikes for a company which has a number of different bike dealers. I need to design the site like this - the dealer signs in on the front page with their unique password given to them (I have the passwords in a database) and the GridView (or maybe something else would be better?) should display only that particular dealer's bikes. Now, this is the tricky part because I have no idea how to achieve that, neither by means of an SQL query nor VB codebehind. Answers would be very much obliged.
NSVisual Basic help!?
Depends on how your database is build. But lets assume you have the password database with something like password_db(key number, password text, for_id number). Now the for id is the id of the byke company. Now you have a second DB which has the companies more or less this structure: byke_companies(key number, name text) now you have the third which have the bikes bikes(key number, bikename text, bykeprice number, for_id number). Now the for_id of both tables are the byke_companies key. So to Select in SQL SELECT * FROM bikes WHERE bikes.for_id = (SELECT for_id FROM password_db WHERE password = 'thepassword') thepassword you have to catch from a field, don't forgett protection, meaning passwordsave your database, make the passwords be a MD5 checksum or something like that, do never store passwords in plaintext. If you do it in a mdb file you should make sure that they cannot open it without password, even if they press ';shift'; and then ';open';. In VB you can run Queries with this command DoCmd.RunSQL (query). If you want a resultset you need following command
Set dbVOA = CurrentDb
Set rstName = dbVOA.OpenRecordset(query)
the rstName is a resultset. Google for that for further information about how to handle this.
Multi column listbox .Net?
I would like to know how to go about creating a multi column listbox. I've searched for about 3 days now and there doesn't seem to a solution for this problem. I've asked this question on multiple forums and most people ask me to use a listview. I cannot use a listview because my requirement is to come up with a multi column listbox, not listview or gridview. I'm also creating a website. So I cannot use a listview. Any kind of help would be appreciated as this problem has been giving me nightmares for the past 3 days. Thanks. Multi column listbox .Net?
Check out the following:
http://www.codeproject.com/KB/cpp/mclb.a鈥?/a>
How to select that cells?
I'm using asp.net (C#), i have a grid view like below:
ID
01 Edit
02 Edit
03 Edit
Then have code:
protected void ibtnEdit_Click(object sender, ImageClickEventArgs e)
{
foreach (GridViewRow gvr in gvwThreads.Rows)
{
Literal litId = (Literal)gvr.FindControl(';litId';);
Response.Redirect(';A.aspx?ID='; + litId.Text, true);
}
}
The edit in the gridview is imagebutton that will link to page A.aspx. When i click on id 01 edit, it'll go to A.aspx with 01 details. But when i click on id 02 or 03 edit, it also go to A.aspx with 01 details but not 02 or 03 details.
Why this happened? How to fix it when i click 01 edit it'll go A.aspx with 01 details %26amp; click 02 or 03 edit will go A.aspx with 02 or 03 details?How to select that cells?
I don't write in C# so you'll have to translate the syntax but...
I think your ForEach loop is assigning ALL rows to the litID. But it quits when it fills the first time. So you need to make sure you're assigning the selected row.
Try a conditional to check the row index = the selected index, like:
For each ...Rows
FindControl
If litID = e (your event argument)
Response.Redirect(';A.aspx?ID='; + litId.Text, true);
end if
NextHow to select that cells?
try
string str
str = GridViewRow.CurrentRow.Cells[0].Value.To鈥?br>
Response.Redirect(';A.aspx?ID='; + str,True);
ID
01 Edit
02 Edit
03 Edit
Then have code:
protected void ibtnEdit_Click(object sender, ImageClickEventArgs e)
{
foreach (GridViewRow gvr in gvwThreads.Rows)
{
Literal litId = (Literal)gvr.FindControl(';litId';);
Response.Redirect(';A.aspx?ID='; + litId.Text, true);
}
}
The edit in the gridview is imagebutton that will link to page A.aspx. When i click on id 01 edit, it'll go to A.aspx with 01 details. But when i click on id 02 or 03 edit, it also go to A.aspx with 01 details but not 02 or 03 details.
Why this happened? How to fix it when i click 01 edit it'll go A.aspx with 01 details %26amp; click 02 or 03 edit will go A.aspx with 02 or 03 details?How to select that cells?
I don't write in C# so you'll have to translate the syntax but...
I think your ForEach loop is assigning ALL rows to the litID. But it quits when it fills the first time. So you need to make sure you're assigning the selected row.
Try a conditional to check the row index = the selected index, like:
For each ...Rows
FindControl
If litID = e (your event argument)
Response.Redirect(';A.aspx?ID='; + litId.Text, true);
end if
NextHow to select that cells?
try
string str
str = GridViewRow.CurrentRow.Cells[0].Value.To鈥?br>
Response.Redirect(';A.aspx?ID='; + str,True);
I have a table (employee) in sqlserver with these fields(Id,Name,Family,Birthdat鈥?,?
Now I want to show the information with asp.net , but I shoulnt use Gridview to show the info , I have to use Tbale instead , but i dont know how to do that , I just know how to show it with grid view using this code:
SqlConnection con = new SqlConnection(ConfigurationManager.Conne鈥?br>
SqlCommand cmd = new SqlCommand(';select * from employee';, con);
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
cmd.Connection.Close();
can you tell me plz how can i do this with table ?I have a table (employee) in sqlserver with these fields(Id,Name,Family,Birthdat鈥?,?
Here's something to get you started. Make sure you are implementing the System.Data interface as well:
SqlConnection con = new SqlConnection(ConfigurationManager.Conne鈥?br>
SqlCommand cmd = new SqlCommand(';select * from employee';, con);
cmd.Connection.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
TableRow tRow = new TableRow();
TableCell cellOne = new TableCell();
// Add as many table cells as you need...
cellOne.Text = row[';ColumnName';].ToString();
// Update the cells' text properties. You can also update the
// properties of the row based on DB criteria.
// Add the cell to the row
tRow.Cells.Add(cellOne);
// Add the row to the table
Table.Rows.Add(tRow);
}
SqlConnection con = new SqlConnection(ConfigurationManager.Conne鈥?br>
SqlCommand cmd = new SqlCommand(';select * from employee';, con);
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
cmd.Connection.Close();
can you tell me plz how can i do this with table ?I have a table (employee) in sqlserver with these fields(Id,Name,Family,Birthdat鈥?,?
Here's something to get you started. Make sure you are implementing the System.Data interface as well:
SqlConnection con = new SqlConnection(ConfigurationManager.Conne鈥?br>
SqlCommand cmd = new SqlCommand(';select * from employee';, con);
cmd.Connection.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
TableRow tRow = new TableRow();
TableCell cellOne = new TableCell();
// Add as many table cells as you need...
cellOne.Text = row[';ColumnName';].ToString();
// Update the cells' text properties. You can also update the
// properties of the row based on DB criteria.
// Add the cell to the row
tRow.Cells.Add(cellOne);
// Add the row to the table
Table.Rows.Add(tRow);
}
Subscribe to:
Posts (Atom)