C# - LinkButton Passing Multivalue Possible Clean Solutions
Dec 9, 2010
I once asked for a way to let a linkbutton pass more than one value in the commandArgument and then I reached the approach where I pass a string of multiple values separated by any character and split it into it's original parts...that didn't work out I don't know what was wrong with the splitting!
Now I tried the only solution I got, which is created a user control of the LinkButton and add properties to accept any values nedeed!...could you please tell me what's wrong with my 2 approaches and which is better ?
The first question can be found here : link text
and this is the code for the user control approach >>
MultivaluedLinkButton.ascx :
<asp:LinkButton ID="LnkBtnSort" runat="server" Text="Sort" OnClick="LnkBtnSort_Clicked"/>
MultivaluedLinkButton.ascx.cs :
public partial class MultivaluedLinkButton : System.Web.UI.UserControl
{
public event EventHandler Click;
private int _sortingType;
private string _sortingFactor;
private string _text;
public int SortingType
{
set { _sortingType = value; }
get { return _sortingType; }
}
public string SortingFactor
{
set { _sortingFactor = value; }
get { return _sortingFactor.ToString(); }
}
//public string Text
//{
// set { _text = value; }
// get { return _text.ToString(); }
//}
protected void LnkBtnSort_Clicked(object sender, EventArgs e)
{
if( Click != null )
{
this.Click(this, EventArgs.Empty);
}
}
}
Finally, Here's the implementation of my control inside an aspx page:
protected void MultivaluedLinkButton1_Clicked(object sender, EventArgs e)
{
MultivaluedLinkButton ctrl = (MultivaluedLinkButton)sender;
using (SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
{
using (SqlCommand cm1 = new SqlCommand(commandString2, cn1))
{
cm1.Parameters.Add("@arrange_by_id", System.Data.SqlDbType.Int);
cm1.Parameters["@arrange_by_id"].Value = ctrl.SortingType;
cn1.Open();
using (SqlDataReader dr1 = cm1.ExecuteReader())
{
SortBy_rpt.DataSource = dr1;
SortBy_rpt.DataBind();
}
}
}
}
The item template of the repeater in the implementation page :
<ItemTemplate>
<uc1:MultivaluedLinkButton ID="MultivaluedLinkButton1" runat="server" OnClick="MultivaluedLinkButton1_Clicked" SortingType='<%#Eval("arrange_by_id")%>' />
</ItemTemplate>
View 1 Replies
Similar Messages:
Jan 4, 2010
I have created an ASP.NET page and included a ReportViewer on the page.
I have created a report with a parameter for an item ID for a row from the database.
After generating a multivalue parameter, I send it to the report, but only the first item in the list is displaying.
In my included code, I am using a FOR loop to generate a list of ID's I want to print a detail for (one detail per page), but eventually I am going to allow a user to select the ID's from a GridView, generate the reports and then print.
Here is the parameter definition from the report:
<ReportParameters>
<ReportParameter Name="ParmWorkOrderID">
<DataType>Integer</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>Report_Parameter_0</Prompt>
<MultiValue>true</MultiValue>
<Hidden>true</Hidden>
</ReportParameter>
</ReportParameters>
---------
Here is the code that build the multivalue parameter:
List<ReportParameter> paramList = new List<ReportParameter>();
ReportParameter param = new ReportParameter("ParmWorkOrderID");
// Create the ArrayList of values to pass
ArrayList values = new ArrayList();
for (int i = 19; i < 50; i++)
{
param.Values.Add(i.ToString());
}
// Add the parameter to the list of ReportParameters
paramList.Add(param);
// Set the reports parameters
this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] {param});
-------------------------------------------
Finally, here is the filter I have on the report:
<Filters>
<Filter>
<FilterExpression>=Fields!WorkOrderID.Value.ToString</FilterExpression>
<Operator>In</Operator>
<FilterValues>
<FilterValue>Parameters!ParmWorkOrderID.Value</FilterValue>
</FilterValues>
</Filter>
</Filters>
So, why won't the reporting engine pump out one page or row (if I use a table on the report) for each of the ID's sent over as parameters?
View 1 Replies
Jul 28, 2010
I want to know, how do i send a multivalue parameter from C# to Stored Procedure which is used in WHERE CLAUSE in IN statement?
for eg:
CREATE PROCEDURE [dbo].[sp_GetPolicyDivOff1]
@Insid varchar(5000)=null
AS
SET NOCOUNT ON
SELECT MST_GroupCompany.GC_Name,MST_DivisionalOffice.DIV_Name FROM MST_DivisionalOffice INNER JOIN MST_GroupCompany ON
MST_DivisionalOffice.DIV_FK_GC_ID=MST_GroupCompany.GC_ID where GC_Name IN(@Insid)
View 10 Replies
Apr 4, 2011
I want to Add product with Solr.net Schema file. my database Table is
Category table - catid, catname
Brand table - brandid, brandname
Item table - productid, productname, productdesc
Filter table- key, value
Note:- if i add all with a Table then data Repeatation occur. so if u have better solution then please suggest me with an examle.
View 1 Replies
Jan 26, 2010
i have DropDownList with sql select commend
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource_department" DataTextField="Department"
DataValueField="Department_No" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource_department" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Department_No], [Department], [Code] FROM [Departments]">
</asp:SqlDataSource>
in the behind code, i can get the value using "DropDownList1.SelectedItem.Value" for Department_No and "DropDownList1.SelectedItem.Text" for Department
but i want also get the selected value "Code"
View 6 Replies
Mar 8, 2010
Im facing problem in one of the reports while passing multivalue parameter from ssrs to SP.
please note that in cases suppose there are single word in multivalue paramtere then its works corretly,in that scenario i have made one function see below:-
[Code]....
and did changes in sp as follow :-
[Code]....
im using ssrs2005.
View 2 Replies
Dec 10, 2010
How to write a MDX expression to pass the value of a multiselected filter while working with ReportAction in Cubes.
I know how to pass the currently selected value, but want to pass the more than one value selected in the filter.
View 1 Replies
Aug 25, 2010
I'm looking for hosting that provides both asp.net (prefer .net 4) and MongoDB. Anyone know any providers?
View 1 Replies
Jan 19, 2011
my qyery is Select * from UserTable .
i set my parameter as @UserId,checked multivalue check box.
in Available values-from query-i set my value and label field.
default value is null.
when i click the preview tab,multiple UserId with check box appear in drop down list...
when i select any one userid ..i get the result for all the userid list instead i want only the selected userid's information...
View 3 Replies
Jan 24, 2010
I'm a ASP.NET MVC Visual Studio, SQL Server web developer. I would like to switch to equivalent open source solutions.
View 4 Replies
Apr 14, 2010
I have 2 sollutions (1 CMS, 1 Customer specific with controls). The customer controls are coppied (with xcopy) to the CMS location. In the web.config of the CMS the specific controls are registered.The controls are useing functions from the CMS dll as well.How can I debug those two solutions as it where only one? I tried to start the CMS in debug mode with breakpoints in de CMS and customer controls, in this case only the breakpoints in the CMS are used. If I run the customer controls in debug mode only the braekpoint in this solution are used.The CMS is running on my local IIS 7.
View 1 Replies
Feb 13, 2011
I have a asp.net application which is written in the traditional method [SqlConnection. SqlAdapter.. ..] in data access layer, I can see that every time we are making a connection and using adapters. Code is written in a very dirty manner. I have been given the task to re write the application in standard/best practice way.
View 3 Replies
Jun 24, 2010
i Want to show data for single employee like this like this
Emp Id : xyz
Emp Name : abc
-------------------------------------------------------
Child name Date of birth education
abc 12/12/2000 o levels
View 5 Replies
Mar 7, 2011
My team is creating several solutions to develop separate branches of the same site. We have some CSS, partials, and master view files that we would like to somehow share between solutions. I have tried linking files but that has to be done for each and every file (cannot link directories, it seems). Does anyone have a tried and true system for doing this sort of thing for larger sites (other than putting everything in one massive solution)?
View 1 Replies
Feb 9, 2010
Whar are equivalent cross-browser solutions for window.showModalDialog? showModalDialog introduced in IE and FF 3.
View 4 Replies
Jun 24, 2010
I'm designing a framework solution DLL with reusable code that I like to use for many different projects,
I want this DLL to be able to load unknown configuration variables dynamically based on the solution its running from.
I like to load my config variables like this: MyConfig.MyVariableX
Hopefully I can also to validate my variables when the web application loads (by type) and make sure it's not missing(otherwise Throw New ApplicationException("Missing..."))
It would also be nice if I can have intellisense on these variables
I want solution A (web application) to have the configuration variables and solution B (DLL) to load the variables from the configuration file in solution A
I'm thinking maybe I should create a database table to hold the variables with types and stuff...
What would be the best way to do it ?
How can I read unknown list of variables names and values from a config file and populate my class with it on runtime ?
View 3 Replies
Feb 23, 2011
My computer's operating system is WIndows 7.I right click a solution file and choose open with notepad by accidently,then after i open my Visual studio 2008 in windows 7,all the solutions are displayed as notepad open mode,i want to change back to normal solution file open mode,How coul i do that?Actually for all the other files,if i right cliked,it will default as notepad,i can not remove this notepad mode.that is odd.
View 3 Replies
Oct 20, 2010
The following works just fine in Chrome.
<asp:LinkButton runat="server" ID="lbEdit" OnClick="lbEdit_Click">
<button type="button" class="edit">
Edit
</button>
</asp:LinkButton>
And here is the CSS for button and its subclass.
[code]...
As you can see, nothing special; just colors and beautiful things.
I click on the blue Edit button and it fires the OnClick postback just fine.... in Chrome! But if I do the same in IE8, it just does nothing; doesn't even detect a click.
I removed the tag and kept just the word "Edit", and it works just fine in IE8 as a simple underlined link; the postback fires.
So, Why can't IE8 accept anything within LinkButton?
View 3 Replies
Aug 24, 2010
I'm considering to host WCF Rest Service that i've built on IIS 7. The URL to access my service will be something like
[URL]
Recently, i've been looking to some REST API implementation with a clean URL like Yahoo API
[URL]
I'm wondering what will be the best WCF host environment (e.g. Windows Service) or any solution (e.g. URL rewrite module) considering that I dont want to have application name and .svc in my URL so that I can have a completely clean URL for my REST API
View 2 Replies
Jan 19, 2010
I'm using asp.net/C# and I'm looking to create unique(?) uris for a small CMS system I am creating.
I am generating the uri segment from my articles title, so for example if the title is "My amazing article" the uri would be www.website.com/news/my-amazing-article
There are two parts to this. Firstly, which characters do you think I need to strip out? I am replacing spaces with "-" and I think I should strip out the "/" character too. Can you think of any more that might cause problems? "?" perhaps? Should I remove all non-alpha characters?
Second question, above I mentioned the uris MAY need to be unique. I was going to check the uri list before adding to ensure uniqueness, however I see stack overflow uses a number plus a uri. This I assume allows titles to be duplicated?
View 3 Replies
Jan 6, 2010
My C# site allows users to submit HTML to be displayed on the site. I would like to limit the tags and attributes allowed for the HTML, but am unable to figure out how to do this in .net.
I've tried using Html Agility Pack, but I don't see how to modify the HTML, I can see how to go through the HTML and find certain data, but actually generating an output file is baffling me.
Does anyone have a good example for cleaning up HTML in .net? The agility pack might be the answer, but the documentation is lacking.
View 6 Replies
May 9, 2010
I am wondering having clear web.config file could be good but you know some shared web hosting companies don't allow us to touch things like machine.config and etc.
So If a lot of things have been moved onto machine.config, then will we be allowed to change things like we used to through web.config file.
View 1 Replies
Aug 11, 2010
There is an image for the surface, and a text is written on the image for 184 rows of date..
Thus, it is expected to see 184 different text written image files are generated with all the same background images. (The code is declared below...)
The problem is that the first text is written for all 184 different data.. I think I have to remove something in the loop. But what is that ??
[Code]....
View 1 Replies
Mar 30, 2011
I'm very new to ASP.net, so I'm just figuring this out.First off, I have multiple separate projects that will be hosted on the same server.Second, they must be able to share certain settings (like connection string, configuration options, etc).Third, those shared settings must be configurable for different deployments (test, prod, etc).
View 1 Replies
May 21, 2010
Is there a better way to write the code below? I have quite a few blocks that are similar, and this is making the code in the Viewpage very messy to work with. The data value with the associated label only needs to be output when certain conditions are met, which is almost always if the value is not null. The options I can think is to use a response.write to atleast minimize the usage of the ASP script tags, or to format the webpage is such a way that the label displays with an appropriate n/a type value.
<% if (myData.Balance != null)
{ %>
Balance: <%= String.Format("{0:C}", (myData.Balance))%>
<% } %>
View 2 Replies