|
Hi! I want to get the row from a table and put in a label. Any clue how this can be solved. Like let's say I have a table with 3 rows, and I want to assign the values from a table to 3 labels
|
|
|
|
|
If you always want to use the same row or automatically determine which row you can use the grid's OnItemDataBound event and the eventArgs parameter will have a reference to the current row, e.Item.Cells[x].Text will get you the value in one cell...or if the cells are named (i.e. not just boundcolumns) you can use e.item.FindControl("name") and get the value that way, but you'll have to cast that to the correct type.
you can also use a button on the form and put your code in the itemCommand event, so the user can pick which row, agin the EventArgs paramter will contain a refernce to the row the clicked button was in.
Hope you found that helpful, Please rate helpful responses, lets us know we're actually giving good answers.
|
|
|
|
|
this seems to me like a good beginning but can you give me some example how to put the data in a label, cause when I am trying to do so, I cannot, I am trying something like this:
protected void GridView1_DataBound(object sender, EventArgs e)
{
Label1.Text = e.Item.Cells[0].Text;
}
it says 'System.EventArgs' does not contain a definition for 'Item'. Any clue? Thanks ahead
actually I cannot see the rows control...I guess
|
|
|
|
|
sorry bout that..my plan works in .NET 1.1, they changed it for .NET 2.0. Assuming your using the RowDataBound event the EventArgs has a property called Row that should work the same way as Item. I havnt tried it yet, all of our code seems to fine, but we only recently upgraded, and are probably still using the old DataGrid controls.
|
|
|
|
|
I recently upgraded from VS 2005 to VS 2008 and found a lot of problems.
The major issue i'm dealing with now is "Error Creating Control"
Here is an example:
HTML
<br />
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<title>Untitled Page</title><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<ASP:SCRIPTMANAGER ID="ScriptManager1" runat="server" /><br />
<div><br />
</div><br />
<ASP:REPEATER ID="Repeater1" RUNAT="server"><br />
<ITEMTEMPLATE><br />
</ITEMTEMPLATE><br />
</ASP:REPEATER><br />
</form><br />
</body><br />
</html><br />
In the designer I get the following error message on the control:
Error Creating Control - Repeater 1
Property 'ITEMTEMPLATE' does not have a property named 'MAPID'.
Does anyone know how to fix this?
Any help would be great!
Thanks,
Will
I hate users. Not all of them, just the ones who talk.CP member: Al Einstien
|
|
|
|
|
I have two master pages in my application both have menu controls. for first one website map is its data source. now for second menu control in second master page what can i use as its data source. i hve tried xml file but it displays only one main menu while need two main menus. how can i? Help Please.
|
|
|
|
|
Hi,
You can use the same web.sitemap to display two menus in two separate master pages. Here is what you need to do.
Let’s assume you have two master pages called, MasterPageOne.master and MasterPageTwo.master and you want to bind a ‘user’ links to one page and ‘customer ‘links to another page.
Construct your web.sitemap in this structure.
[Web.sitemap] - code
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode title="Home" url="~/Default.aspx" roles="*">
<siteMapNode title="Products" url="" />
<siteMapNode title="Users" url="~/Users.aspx" >
<siteMapNode title="Users Personal Info" url=""></siteMapNode>
<siteMapNode title="Users Applications" url=""></siteMapNode>
<siteMapNode title="Users Departments" url=""></siteMapNode>
<siteMapNode title="Users Cover" url=""></siteMapNode>
</siteMapNode>
<siteMapNode title="Customers" url="~/Customers.aspx" >
<siteMapNode title="Customer Personal Info" url="">
<siteMapNode title="Customer Personal Info-Details" url="">
</siteMapNode>
</siteMapNode>
<siteMapNode title="Customer Orders" url=""></siteMapNode>
<siteMapNode title="Customer Enquiries" url=""></siteMapNode>
<siteMapNode title="Customer Other" url=""></siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>
Configure the both menu controls with the same DataSourceID. But, specifying a different StartingNodeUrl property for each SiteMapDataSource. So here is how it will look like.
[MasterPageOne.master]-code
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" StartingNodeUrl="~/Customers.aspx" />
<h2>
Customer Links</h2>
<asp:Menu ID="Menu2" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
[MasterPageTwo.master]-code
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" StartingNodeUrl="~/Users.aspx" />
<div>
<h2>
Users Links</h2>
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
The main concept is that we construct both menus in the same web.sitemap(look closely at this code – all child nodes for uses are under user and all child nodes for customer are under customer) but we configure the StartNodeUrl that will specify the starting point of each. But this way, you can create your own menus to display in any number of master pages and menu levels - to any depth. Hope it’s clear.
Thx,
Gayani
|
|
|
|
|
Thanx a lot
It worked good.
|
|
|
|
|
hello friends,
I am using datagrid to list my items. I am using sqldatasource for this. but while deleting record, i want to add confirmation javascript before delete? Is it possible on datagrid?
Amit
|
|
|
|
|
Its not that easy to add in javascript to a c# script which is going to run at the server, I would try and create something through asp.net which would perform a similar task
We are not a Code Charity
|
|
|
|
|
Here is an example that should point you in the right direction. In the aspx page (datagrid property) add onItemDataBound = "itemDataBound"
Codebehind should be something like this.
protected void itemDataBound(object o, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
LinkButton lb = (LinkButton)e.Item.FindControl("lLinkButton");
lb.Attributes.Add("onClick", "return confirm('Are you sure want to delete ?')");
}
}
I didn't get any requirements for the signature
|
|
|
|
|
Hi all,
I want to know how to use datagird in inserting, updating and deleting processes, also i want to know how to put dropdownlist as al column in the datagrid and use its values
Pleas any one help me ASAP
Thanks for help
|
|
|
|
|
So what is the problem? There are countless documentation describing what you want to do.
|
|
|
|
|
Thanks for your help
But if you can, please send to me tha most useful one
|
|
|
|
|
http://www.google.co.uk/search?hl=en&q=asp.net+datagrid+insert+delete&btnG=Google+Search&meta=
We are not a Code Charity
|
|
|
|
|
Hi this is manoj,
I am currently working on radio channel project.I have to make a player in which user can watch video
pls help me .
manojmkp@gmail.com
|
|
|
|
|
Why can't you use WMP (Windows Media Player)?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
I have placed a menu control in my master page (see definition below) but the formatting is being ignored. The submenu is displayed when the page is first loaded and is not indented. If I place the same menu definition in a normal page it is formatted correctly. Both appear correctly in design view. I've tried playing around with various properties but anything I set is ignored in the master page.
Can anyone tell me what I'm doing wrong please?
This is the menu definition:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal">
<StaticMenuItemStyle ItemSpacing="10px" />
</asp:Menu>
And this is web.sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Main.aspx" title="Home " description="Home">
<siteMapNode url="Environment.aspx" title="Environment " description="Switch environment"/>
<siteMapNode title="Reports" description="Generate and view reports">
<siteMapNode title="Report1" url="Reports/Report1.aspx"/>
<siteMapNode title ="Report2" url="Reports/Report2.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>
|
|
|
|
|
I've just tried this in Firefox and it displays as expected so it appears to be an IE problem (version 6). Not that I'm any the wiser as to how to solve it!
|
|
|
|
|
Hi,
Would someone be able to tell me how to go about doing the following (at least conceptually)....
I am building an ecommerce store and want to have current stock levels showing on the site. When a customer puts an item in his basket - the stock levels should be reduced by the quantity he has chosen temporarily. If he completes the purcahse the stock levels are reduced permeantly. If he does not compelte the purchase or closes the browser the stock levels return to the original amount. But while he has it in his basket - the stock levels should show the total less the one he has. Eg If there is only one left and he puts it in his basket - the stock level shows zero until he either buys it or does not. If he does not then the stock levels return to 1. Also, how do i deal with the situation where he just closes his browser with the item in the basket - how do i reset the stock level? Apologies for the long post but i wanted to try to get all the questions out!
Thanks
rdhon
|
|
|
|
|
You should put a timer on how long the product is in his basket
e.g
Customer puts product in basket(table) record time and date
Set a timer for say 20 minutes and 20 mintues from the time the item was added delete it from the basket
This way you solve the problem of not knowing when a user closes their browser.
We are not a Code Charity
|
|
|
|
|
Hi
In my web application i want to allow access to my web application only those user whose entry exsist in web.config file
<identity impersonate="true" userName="s717369" password="pa$$w0rd"/>
Note there is no any domain exsist, i want to give access in my application to only those user who is giving this userid and password same as web.config during windows login.
Sajid A.
|
|
|
|
|
It would be much better if your ID and password were being compared to a database login but if you want a solution for the above check this out:
http://msdn.microsoft.com/en-us/library/aa292118(VS.71).aspx
We are not a Code Charity
|
|
|
|
|
hi all! I have an issue and I really don't know how to solve. I am building a web app, and I am loading a XML Document. After I am loading the document, I want on the web site to display a data table with the data from the xml document. I want the data to be populated depending from the data what I have in the xml document. For example:
<Employees>
<Employee ID="1">
<Name>John</Name>
<Status>ProjectManager</Status>
</Employee>
<Employee ID="2">
<Name>Samantha</Name>
<Status>SoftwareDeveloper</Status>
</Employee>
</Employees></code>
then from that xmldocument I want to populate a datatable. Is that possible? Thanks ahead
|
|
|
|
|
Simply read the xml data to dataset.
Dataset ds = new dataset();
ds.readxml('xmlfilepath');
Datatable dt = new Datatable();
dt = ds.tables[0];
G. Satish
|
|
|
|