HyperLink or Link on PivotGridField with DevExpress - ASP.NET With C# - c#

[This shows the lots count of every step in the process of manufacturing the product, but I want to know if its possible to make a link to know which lots are included in this lots count, I'm using dx:pivotGridField, inside a dx:ASPxPivotGrid all with devexpress, the only thing that I don't know is that if a can put a link on every single data of that column, click on any number to send me a chart with the info of that lots.
Thanks!]1

You can use ValueTemplate
<dx:PivotGridField Area="ColumnArea" AreaIndex="0" FieldName="ConsumptionDate" ID="fieldConsumptionMonth">
<ValueTemplate>
<dx:ASPxHyperLink ID="ASPxHyperLink1" runat="server" ondatabinding="OnHyperLinkDataBinding" NavigateUrl='test.aspx' />
</ValueTemplate>
</dx:PivotGridField>
And then set the text in the backend
protected void OnHyperLinkDataBinding(object sender, EventArgs e) {
ASPxHyperLink link = (ASPxHyperLink)sender;
link.Text = ((PivotGridFieldValueTemplateContainer)link.Parent).Text;
}

Related

VIsual Web Developer Radio Button - Update Live

I am currently trying to develop a form/website using Microsoft Visual Web Developer 2010 Express.
In the first section is a group of radio buttons which control the subject line field. I have been able to add a RadioButtonCheckedControl attribute which will set the subject line BUT it will only work if the page is refreshed. Is there a command to live update the form?
In the ascx file there is the following:
<asp:RadioButton ID="RadioUniform" runat="server" Text="Uniform Infringement"
GroupName="Reason" oncheckedchanged="RadioUniform_CheckedChanged" />
And then in the ascx.cs file there is the following:
protected void RadioUniform_CheckedChanged(object sender, EventArgs e)
{
CommentSubject.Text = "UNIFORM INFRINGEMENT";
}
So after a couple of quick Google searches (as I've done previous nights) I found the solution. After the OnCheckedChanged part of the radio button code, add AutoPostBack="True".

How to set 'mouseover' event for per gridview row?

I'm using ASP.NET (C#). I have designed a gridview and loaded data from database (SQL Server). That's ok.
Here is advanced requirement:
-> The database contains a field that it cannot be showed while debugging. Because I had wrote:
<asp:BoundField DataField="course_group" HeaderText="Course group" SortExpression="course_group" HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden" />
In css:
.hidden
{
display: none;
}
-> Now, I wanna get the value of course_group and set it into gridview row as a "Tooltip". Like this:
Visit W3Schools.com!
I know the way to write a link tooltip, but not for gridview row tooltip.
I think it's difficult, because you might want to many different tooltip text for all gridview rows
Is there anyway to do that?
Can you give me any C# code behind solution (mouseover event) or CSS/Javascript code solution (hover event)?
Thank you!
Try:
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.ToolTip = (e.Row.DataItem as DataRowView)["Description"].ToString();
}
}
Reference Here

Populate DropDownList inside Grid Template Column

I have a dropdownlist inside a template column on a obout grid. Currently i am populating the dropdownlist on page load with a sqldatasource. However, i now have to load the dropdownlist dependent on the value of a certain column. For example: If status = 1, i populate the dropdownlist with a list of available options that pertain to status 1.
<obout:Column ID="colStatus" DataField="wf_status_id" Align="center" HeaderText="Status" HeaderAlign="center" Width="130px" Wrap="true" runat="server" AllowGroupBy="true" AllowFilter="true">
<TemplateSettings EditTemplateId="tmpStatusIDEdit" TemplateId="tmpStatusID" />
</obout:Column>
<obout:GridTemplate runat="server" ID="tmpStatusID" >
<Template>
<%# Container.DataItem["Status"]%>
</Template>
</obout:GridTemplate>
<obout:GridTemplate runat="server" ID="tmpStatusIDEdit" ControlID="ddlStatus" ControlPropertyName="value">
<Template>
<obout:OboutDropDownList runat="server" ID="ddlStatus" Width="100%" Height="200" MenuWidth="215" DataSourceID="sdsStatus" DataTextField="wf_status_text" DataValueField="wf_status_id" />
</Template>
</obout:GridTemplate>
public void OnGridRowDataBound(object sender, Obout.Grid.GridRowEventArgs e)
{
if (e.Row.RowType == Obout.Grid.GridRowType.DataRow)
{
DropDownList ddlStatus = new DropDownList();
ddlStatus = (DropDownList)e.Row.FindControl("ddlStatus");
//LOAD DROP DOWN HERE//
}
}
When i attempt to execute this code, it shows that ddlStatus is null everytime. I have a tried a multitude of ways to get this and for some reason cannot seem to get it. Perhaps aother set of eyes or other ideas could help me out. Please let me know what it is i am doing wrong. Thank you ahead of time
UPDATE:DATABOUND EVENT CODE
<obout:OboutDropDownList runat="server" ID="ddlStatus" Width="100%" Height="200" MenuWidth="215" OnDataBinding="ddlStatus_DataBinding" DataSourceID="sdsStatus" DataTextField="wf_status_text" DataValueField="wf_status_id" />
protected void ddlStatus_DataBinding(object sender, EventArgs e)
{
Obout.Interface.OboutDropDownList ddl = (Obout.Interface.OboutDropDownList)(sender);
string statusID = Eval("wf_status_id").ToString();
}
I added the DataSource because i do not see another way to have the databinding event triggered.
I don't really know anything about obout controls but I have to assume they act very similar to the asp.net controls and have just been extended. With that assumption in mind, I will try and answer your question.
Your RowDataBound event has a few coding issues... for example, I am not sure why you are defining a new DropDownList and then trying to overwrite it with the next line. Also it sounds like the next line is returning null anyways.
First off I suggest not using the DataBound event at the row level. Use the control's DataBinding event as it will localize your code a lot better because you can trigger off the specific control's DataBinding and therefore not have to search for it. If your code changes (markup or codebehind) it is also a lot easier to change as it will not affect other things and there is less room for introducing bugs.
So I would make the following changes to address this:
Change your DropDownList definition to implement DataBinding:
<obout:OboutDropDownList runat="server" ID="ddlStatus" Width="100%" Height="200"
MenuWidth="215" OnDataBinding="ddlStatus_DataBinding" />
Then implement the OnDataBinding event (get rid of your DataBound event if you weren't using it for anything else):
protected void ddlStatus_DataBinding(object sender, System.EventArgs e)
{
// This will point to ddlStatus on the current row that is DataBinding so you
// don't have to search for it.
OboutDropDownList ddl = (OboutDropDownList)(sender);
// Now you can fill the DropDownList and set the default value how ever you like
...
}
You can also see this other question I answered a long time ago to see if it helps as it is doing the same thing but with a Repeater but it is pretty much the same thing as a grid:
Populating DropDownList inside Repeater not working
EDIT: Changed the code to use OboutDropDownList in the DataBinding.
you can find plenty of samples on obout knowledge base and examples. These should help you out: http://www.obout.com/combobox/aspnet_integration_grid.aspx, http://www.obout.com/grid/aspnet_ajax_cascading_comboboxes.aspx
(they refer to comboBox, but you can easily adapt them do a ddl)

How to make GridView take me to a different page

I;m new on SO so please be gentle. I searched and didn't find what I was looking for.
My problem is as follows - I am making a game for Windows Store where you must finish sentences based on the animation you see below the sentence. The game will offer many stories and this is my problem. I used the default GridView template to create the MENU for picking your stories. And this is where I am stuck:
How to tell the app using json that when clicked it should open a specific page (the wanted level)?
This is the code that I need to change probably:
void ItemView_ItemClick(object sender, ItemClickEventArgs e)
{
// Navigate to the appropriate destination page, configuring the new page
// by passing required information as a navigation parameter
var itemId = ((SampleDataItem)e.ClickedItem).UniqueId;
this.Frame.Navigate(typeof(ItemDetailPage), itemId);
}
I know that I need to change the last line so that it takes some information from the json file and changes it for a specific page file name from the solution.
I hope that you understand what I mean :(
Use the template field to add a button with your routing argument.
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text="Action" CommandName="Action"
CommandArgument='<%#Bind("ID ") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Code Behind:
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Action")
{
string ID = e.CommandArgument; // Do something with it.
}

Display data from XMLDataSource in TextBox

Can anyone give me some pointers on how to display the results of an XPath query in a textbox using code (C#)? My datascource seems to (re)bind correctly once the XPath query has been applied, but I cannot find how to get at the resulting data.
Any help would be greatly appreciated.
XMLDataSource is designed to be used with data-bound controls. ASP.NET's TextBox is not a data-bound control. So to accomplish what you want you either have to find a textbox control with data binding or display the result in some other way.
For example, you could use a Repeater control and create your own rendering template for it.
<asp:Repeater id="Repeater1" runat="server" datasource="XMLds">
<ItemTemplate>
<input type="text" value="<%# XPath("<path to display field>")%>" />
</ItemTemplate>
</asp:Repeater>
Some more information would be nice to have to be able to give you a decent answer. Do you have any existing code snippets you could publish here?
The general idea is to use the XmlDataSource.XPath property as a filter on the XmlDataSource.Data property. Did you try displaying the contents of the Data prop in your textbox?
Based on a slection in a DropDownList, when the SelectedIndexChanged event fires, the XPath for an XMLDataSource object is updated:
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
XMLds.XPath = "/controls/control[#id='AuthorityType']/item[#text='" + ddl.SelectedValue + "']/linkedValue";
XMLds.DataBind();
}
The XPath string is fine, I can output and test that it is working correctly and resolving to the correct nodes. What I am having problems with, is getting at the data that is supposedly stored in the XmlDataSource; specifically, getting the data and outputting it in a TextBox. I'd like to be able to do this as part of the function above, i.e.
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
XMLds.XPath = "/controls/control[#id='AuthorityType']/item[#text='" + ddl.SelectedValue + "']/linkedValue";
XMLds.DataBind();
myTextBox.Text = <FieldFromXMLDataSource>;
}
Thank you for your time.

Categories

Resources