Code
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" OnTabClick="RadTabScript1_TabClick" OnClientTabSelecting="onTabSelecting" > <%-- OnClientTabSelecting="onTabSelecting"> --%>
<Tabs>
<telerik:RadTab Text="Resources" runat="server" TabIndex="0" Selected="true" PageViewID="radPageResources"></telerik:RadTab>
<telerik:RadTab Text="Tasks" runat="server" TabIndex="1" PageViewID="radPageTasks"></telerik:RadTab>
<telerik:RadTab Text="Messages" runat="server" TabIndex="2" PageViewID="radPageMessages"></telerik:RadTab>
<telerik:RadTab Text="Files" runat="server" TabIndex="3" PageViewID="radPageFiles"></telerik:RadTab>
<telerik:RadTab Text="Feedback" runat="server" TabIndex="4" PageViewID="radPageFeedback"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated" SelectedIndex="0" > <%-- RenderSelectedPageOnly="true" > --%>
<telerik:RadPageView ID="radPageResources" runat="server" TabIndex="0">
<telerik:RadGrid runat="server" ID="grdResource" PageSize="5" Skin="Default" AllowPaging="True"
AllowSorting="true" ShowFooter="true" AutoGenerateColumns="False" Width="97%"
OnItemCreated="grdResource_ItemCreated" OnNeedDataSource="grdResource_NeedDataSource"
OnDeleteCommand="grdResource_DeleteCommand" ShowStatusBar="True" GridLines="None"
OnItemDataBound="grdResource_ItemDataBound">
</telerik:RadGrid>
Like this i have 4 pageview tabs with indexes and every pageview tab contains a grid.If suppose i did changes in some x-grid and causes postback,then i need the x-grid should be shown after the postback. But i was showing the Resourcegrid.
codebehind
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
RadMultiPage1.SelectedIndex = e.PageView.TabIndex;
}
but this event not firing in any case.
so how can i come back to the previous grid even when postback occurs?
try set selected index in page_prerender.
protected void Page_PreRender(object sender, EventArgs e)
{
//RadTab t1 = new RadTab();
//RadMultiPage m1 = new RadMultiPage();
m1.SelectedIndex = t1.SelectedIndex;
}
i don't know my solution can be helpful for this subject or not
I tried all methods and finally find myself method,
i suggest if your problem not solved make java script function and then call it from code behind
My Sample :
function OnClientClick1(i) {
var tabstrip1 = $find("<%=RadTabStrip1.ClientID %>");
tabstrip1.set_selectedIndex(1);
}
and then make function on your code to call that
private void ChangeTab(int index)
{
string scriptyKey = "Alert" + Guid.NewGuid().ToString().Replace("-", "_");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), scriptyKey, "OnClientClick1("+index.ToString()+");", true);
}
I hope be useful
Related
I have used dx:ASPxGridView where I have one dx:GridViewDataTextColumn with EditItemTemplate which contain dx:ASPxListBox. When I click on update command I am not able to get selected items of dx:ASPxListBox under ASPxGridView_Updating.
<dx:ASPxGridView
ID="ASPxGridView"
runat="server"
AutoGenerateColumns="False"
DataSourceID="TradersDS"
KeyFieldName="TraderId">
<SettingsEditing Mode="PopupEditForm" PopupEditFormWidth="600px" />
<ClientSideEvents RowDblClick="function(s, e)
{
s.StartEditRow(e.visibleIndex);
}"
EndCallback="PrepareGridViewForNewDesing" Init="PrepareGridViewForNewDesing" />
<Columns>
....
<dx:GridViewDataTextColumn FieldName="CounterParty" VisibleIndex="3">
<EditItemTemplate>
<dx:ASPxListBox ID="lstCounterParty" runat="server" SelectionMode="CheckColumn" EnableSelectAll="true"
Width="285"
Height="300"
DataSourceID="CounterPartiesDS"
ValueField="ID"
ValueType="System.String"
TextField="Name">
<%-- <ClientSideEvents SelectedIndexChanged="function(s, e) {lbModels.PerformCallback('1');}" />--%>
</dx:ASPxListBox>
</EditItemTemplate>
</dx:GridViewDataTextColumn>
...
</Columns>
</dx:ASPxGridView>
C# Code..
protected override void ASPxGridView_Updating(object sender, ASPxDataUpdatingEventArgs e)
{
var gridView = sender as ASPxGridView;
GridViewDataColumn list = gridView.Columns["CounterParty"] as GridViewDataColumn;
var counterPartyListBox = (ASPxListBox)gridView.FindEditRowCellTemplateControl(list, "lstCounterParty");
string selectedItemsAsString = string.Empty;
foreach (ListEditItem item in counterPartyListBox.SelectedItems)
selectedItemsAsString += item.Value + ";";
base.ASPxGridView_Updating(sender, e);
}
Here I always get count 0 of SelectedItems. On addition to this My devExpress control version are 9.3.3
What is wrong with this code any help , guidance really appreciated.
Make sure that you set the ASPxListBox.ValueType property to the corresponding .NET type that matches the type of the "ValueField" column.
May be, according to the (ValueField="ID"), the (ASPxListBox.ValueType) should be numeric? (System.Int32, etc.)
I have hopefully a simple question. I have a ASPxGridView that I need to pull data from and pass it to a function. A simple way I figured to do this is to use a session variable.
But when I do the Eval binding it shows the characters on screen (as well as putting them into the variable). How do I remove the characters from the screen? Or maybe there is a easier way to do this.
Code is here (real meat is 4th line down):
<dx:GridViewDataButtonEditColumn Caption="" Name="Schedule"
VisibleIndex="11">
<DataItemTemplate>
<%# Session["PatientID"] = Eval("PatientID")%>
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Schedule" OnClick="Button_Click" >
</dx:ASPxButton>
</DataItemTemplate>
</dx:GridViewDataButtonEditColumn>
Try this
<dx:GridViewDataButtonEditColumn Caption="" Name="Schedule" VisibleIndex="11">
<DataItemTemplate>
<dx:ASPxButton ID="ASPxButton1"
runat="server" Text="Schedule"
OnClick="Button_Click"
CommandName='SomeCoolCommandName'
CommandArgument='<%#Eval("PatientID")'>
</dx:ASPxButton>
</DataItemTemplate>
</dx:GridViewDataButtonEditColumn>
On it rowcommand or Itemcommand event check for command and do something..
protected YourGrid_ItemCommand(sender, e)
{
if(e.CommandName.Equals("SomeCoolCommandName"))
{
var id = Convert.ToInt32(e.CommandArgument); // Give you your Patient ID
// do whatever you want to do with your ID
}
}
Try to put a hidden field and bind its value like following
<asp:HiddenField ID="hdnPatientID" runat="server" Value='<%# Eval("PatientID")%>' />
I am adding the functional code here. Thanks all! Using command worked great.
protected void Button_Click(object sender, CommandEventArgs e)
{
string patID = e.CommandArgument.ToString();
Response.Redirect("schedule.aspx?PatientID=" + patID);
}
<dx:GridViewDataButtonEditColumn Caption="" Name="Schedule"
VisibleIndex="11">
<DataItemTemplate>
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Schedule"
CommandName = "PatientID" CommandArgument = '<%# Eval("PatientID")%>' OnCommand="Button_Click" >
</dx:ASPxButton>
</DataItemTemplate>
</dx:GridViewDataButtonEditColumn>
Does a RadTabStrip work in a MasterPage? The tabs do not appear selected when clicked.
Steps:
Create a new Web Application Project. By default it contains Home and About tabs inside a Master Page (Site.Master). The tabs are asp:MenuItem controls.
Comment out the asp:Menu control and drag a RadTabStrip in its place. Add two RadTabs. When you run the application each tab works as expected -- it appears to be selected when clicked.
Now add NavigateUrls to each RadTab pointing to the "~Default.aspx" and "~About.aspx" pages. When the application runs the tabs don't appear to be selected when clicked (although the correct page displays).
What's going on? How can I make this work?
Update: Here's how I altered the default code in Site.Master...
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
</div>
<%--<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu>
</div>--%>
<div>
<telerik:RadTabStrip ID="RadTabStrip1" runat="server">
<Tabs>
<telerik:RadTab runat="server" Text="Root RadTab1" NavigateUrl="~/Default.aspx">
</telerik:RadTab>
<telerik:RadTab runat="server" Text="Root RadTab2" NavigateUrl="~/About.aspx" >
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
</div>
The answer...
Bojan Skrchevski's answer led me to this. I added this code to the Master Page's Page_Load event and it works:
using Telerik.Web.UI;
namespace WebApplication1
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
RadTab currentTab = RadTabStrip1.FindTabByUrl(Request.Url.PathAndQuery);
if (currentTab != null) currentTab.Selected = true;
}
}
}
I think that you also need to add runat="server" to the RadTab element if you want to use it like that. For example:
<telerik:RadTab Text="Home" NavigateUrl="Default.aspx" runat="server">
</telerik:RadTab>
You can also use ContentUrl in the corresponding telerik:RadPageView to navigate on the client side. Example:
<telerik:RadPageView ID="RadPageView1" runat="server" ContentUrl="Default.aspx">
UPDATE(on your update):
When you add runat="server" to the RadTab then it causes a postback. On postback the control is unable to determine which tab is selected even though it navigates to the specified page. Here's how it is solved in the Telerik example:
protected void Page_Load(object sender, System.EventArgs e)
{
string urlWithSessionID = Response.ApplyAppPathModifier(Request.Url.PathAndQuery);
RadTab tab = RadTabStrip1.FindTabByUrl(urlWithSessionID);
if (tab != null)
{
tab.SelectParents();
tab.PageView.Selected = true;
}
}
The only difference I can see in your code compared to my master page is SelectedIndex="0" on the RadTabStrip and Selected="true" on one of the Rad Tabs:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0">
<Tabs>
<telerik:RadTab runat="server" Text="Root RadTab1" NavigateUrl="~/Default.aspx" Selected="true">
</telerik:RadTab>
<telerik:RadTab runat="server" Text="Root RadTab2" NavigateUrl="~/About.aspx" >
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
I want to take advantage of the breadth of attributes available to a LinkButton compared to a CommandField. When calling the code behind method from on click I get this error message:
CS0123: No overload for 'ViewHandler' matches delegate
'System.EventHandler'.
GridView definition:
<asp:GridView ID="wc" EmptyDataText="Empty WC table..." runat="server"
AutoGenerateColumns="False" GridLines="Horizontal" DataKeyNames="WC_ID,PW_ID,R_Qty"
CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
AllowSorting="true" OnSorting="Sorting" AllowPaging="true" PageSize="15" ViewStateMode="Enabled"
OnSelectedIndexChanging="ViewHandler" OnPageIndexChanging="HandlePageIndexChanging" OnRowDataBound="gvRowDataBound"
OnRowEditing="gvRowEditing" OnRowCancelingEdit="gvRowCancelingEdit" OnRowUpdating="gvRowUpdating">
Orig button...
<asp:CommandField ControlStyle-Font-Size="Smaller" ControlStyle-ForeColor="#717171" HeaderText="..." ShowSelectButton="True" ItemStyle-HorizontalAlign="Center" SelectText="..." />
Convert to....
<asp:TemplateField HeaderText="..." ShowHeader="True" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:LinkButton style="font-size: 0.9em; color: #717171" ID="Details" runat="server" CausesValidation="False" OnClick="ViewHandler" CommandName="ViewHandler" Text="..." ToolTip="Click here to see purchase history and notes"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Code behind:
protected void ViewHandler(object sender, GridViewSelectEventArgs e)
{
string WC_ID =wc.Rows[e.NewSelectedIndex].Cells[0].Text;
string PW_ID = wc.Rows[e.NewSelectedIndex].Cells[1].Text;
string VIN = wc.Rows[e.NewSelectedIndex].Cells[2].Text;
string PROD = wc.Rows[e.NewSelectedIndex].Cells[3].Text;
string W = wc.Rows[e.NewSelectedIndex].Cells[4].Text;
string SIZE = wc.Rows[e.NewSelectedIndex].Cells[5].Text;
e.Cancel = true;
Session.Add(WebConstants.WC_ID, WC_ID);
Session.Add(WebConstants.PW_ID, PW_ID);
Session.Add(WebConstants.VIN, VIN);
Session.Add(WebConstants.PROD, PROD);
Session.Add(WebConstants.W, W);
Session.Add(WebConstants.SIZE, SIZE);
DetailsNavigateMethod.DynamicInvoke();
HandlePageNavigation(WebConstants.WC_DETAILS, "WC View for WC_PurchaseID-> " + Session[WebConstants.WC_ID].ToString());
}
What do I need to do to make the signature match with the ViewHandler method? I did notice if I switch from GridViewSelectEventArgs to EventArgs the overload error goes away but then e.NewSelectedIndex does not exists...
Thanks!
Your problem is that the OnClick event handler for a LinkButton must have this signature:
protected void LinkButton_Click(Object sender, EventArgs e)
But you are defining it as
protected void ViewHandler(object sender, GridViewSelectEventArgs e)
However, you won't have access to e.NewSelectedIndex, obviously. What you can do is change your markup to (notice the CommandArgument part):
<asp:TemplateField HeaderText="..." ShowHeader="True" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:LinkButton style="font-size: 0.9em; color: #717171" ID="Details" runat="server" CausesValidation="False" OnClick="ViewHandler" CommandName="ViewHandler" CommandArgument='<%=string.Format("{0},{1},{2},{3}",Eval("Prop1"),Eval("Prop2"),Eval("Prop3"),Eval("Prop4")) %>' Text="..." ToolTip="Click here to see purchase history and notes"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
And your code to:
protected void LinkButton_Click(Object sender, EventArgs e)
{
string [] values = ((LinkButton)(sender)).CommandArgument.Split(new char[]{','});
//where values[0] will have WC_ID, values[1]=PW_ID, etc,
Session.Add(WebConstants.WC_ID, values[0]);
Session.Add(WebConstants.PW_ID, values[1]);//etc...
//Session.Add(WebConstants.VIN, VIN);
//Session.Add(WebConstants.PROD, PROD);
//Session.Add(WebConstants.W, W);
//Session.Add(WebConstants.SIZE, SIZE);
DetailsNavigateMethod.DynamicInvoke();
HandlePageNavigation(WebConstants.WC_DETAILS, "WC View for WC_PurchaseID-> " + Session[WebConstants.WC_ID].ToString());
}
Note:
Prop1, Prop2, etc. have to be changed to actual property names from your data source.
Above code hasn't been tested but that's the idea.
I have a gridview like this:
<asp:GridView ID="gv1" AutoGenerateColumns="false" BorderWidth="0" runat="server" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<span style="font-family:Tahoma; font-size:14px;">
<u> <a href="<%#DataBinder.Eval(Container.DataItem,"ShUrl")%>">
<%#DataBinder.Eval(Container.DataItem,"PostTitle")%>
</a>
</u>
<br />
</span>
<asp:Repeater ID="rp1" runat="server">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li >
<%# Eval("TagName")%>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Now I am able to load successfull ShUrl and PostTitle. I am bringing titleId from the database also.
Now as usual, a post might have several tag. So I want to load the repeater for the particular titleId.
On server side, I am simply binding the gv1 from the datable.
Now how to load tags for the titleid:
I have already written the function on the server side, might help you all to guide me:
private void LoadtagList(int titleId)
{
// calling DAL
rp1.DataSource = db.GetAllTagsForPost(titleId);
rp1.DataBind();
}
you have to use GridView RowDataBound Event for that
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
System.Data.DataRowView dr = (System.Data.DataRowView)e.Row.DataItem;
if (Convert.ToString(dr["titleId"]) != "")
{
Repeater rp1 = (Repeater)e.Row.Findcontrol("rp1");
rp1.DataSource = db.GetAllTagsForPost(titleId);
rp1.DataBind();
}
}
}