C# - Constructing Paramater Query SQL - LIKE % In .cs And In Grid View?

May 19, 2010

I am trying to implement admin login and operators(india,australia,america) login, now operator id starts with 'IND123' 'AUS123' and 'AM123'

when operator india logs in he can see the details of only members have id 'IND%', the same applies for an australian and american users

and when admin logs in he can see details of members with id 'IND%' or 'AUS%' or 'AM%'

i have a table which defines the role i.e admin or operator and their prefix(IND,AUS respectively)

In loginpage i created a session for Role and prefix

PREFIX = myReader["Prefix"].ToString();
Session["LoginRole"] = myReader["Role"].ToString();
Session["LoginPrefix"] = String.Concat(PREFIX + "%"); works fine

In main page(after login) i have to count the number of member so i wrote

string prefix = Session["LoginPrefix"].ToString();
string role = Session["LoginRole"].ToString();
if (role.Equals("ADMIN"))
StrMemberId = "select count(*) from MemberList";
else
StrMemberId = "select count(*) from MemberList where MemberID like '"+prefix+"'";

Problem: 1. i want to constructor parameter something like

StrMemberId = "select count(*) from MemberList where MemberID like '@prefix+'";
myCommd.Parameters.AddWithValue("@prefix", prefix);

Which is not working

2 Displaying the members in gridview i need to give condition (something like if (role.Equals("ADMIN")) show all members else show member depending on the operator prefix)the list of members in operator mode and admin mode. - where to put the condition in gridview how to apply these

View 2 Replies


Similar Messages:

ADO.NET :: Constructing A Linq Query Using A Collection?

Mar 13, 2011

I'm constructing a query using linq, but I'm having trouble using a collection, i.e. where field in database = anything in the collection.

Below is an example of what I mean:

dim keywords as string ="test,test2,test3,cats,dogs,frogs"
Dim getKeywords = (From cp In myDataContext.pages
Where cp.pageKeywords = currentPageKeywords.Split(",")

The aim of the above code is to return all records where the "pageKeywords" field contains 1st keyword, or 2nd keyword, or 3rd keyword etc.

View 5 Replies

C#- Dynamically Constructing An Url Query String?

Oct 12, 2010

I need to dynamically construct a url by appending new parameter to the current url.

I know how to do this in the long way by getting the current url and check if there is any QueryString, if no add "?" if yes add "&". Also check is the parameter is already exist. If yes change the value.

But is there any build in .NET function to do this? Like Request.QueryString.Add

View 1 Replies

Forms Data Controls :: Drive A Grid View From More Than One Query?

Sep 20, 2010

I have a Calendar Control on one page - the user clicks on a date and goes to another page which displays the details from a diary database for the selected date - works fine so far! Now, whilst on that second page I want to give the User the choice of displaying all diary entries for the month, or for the year. So I could create a further 2 separate pages that display a GridView for a particular Month or a particular Year but that seems a bit of an over kill.

How can I make the Grid View display from different queries or maybe dynamically change the query depending upon whether a Month or Year is selected? So my start page with the Calendar Control has this code:

[Code]....

After which the User gets taken to diaryPage.aspx with the Selected Date from the Calendar Control. I then created a Table Adapter on the diary Page to query the diary Database with the Selected Date and drive the Grid View to display the details for that Selected Date.

[Code]....

SO on that page, how do I now let the User query by Month or Year using the same Grid View? Maybe there is some generic SQL statement that could retrieve either the Selected Day, or Year or Month depending on the parameters sent to it?

View 5 Replies

Forms Data Controls :: Trigger Edit Mode In Grid View Using Query String?

Feb 10, 2010

I have a page that displays a grid view based on a query string. When I click the edit button I need to send the grid view into edit mode based on the query string. I have this so far:

[Code]....

When I requested the page the first time, the grid view displayed properly, and when I clicked the edit link button, it did trigger the update mode. However, I can't get the cancel mode to operate properly; in other words, cancel never sends it back to normal mode, as a result, with each new page request, I'm always stuck on the last edited record.

View 1 Replies

Forms Data Controls :: Have A Grid View With Some Coulmns Like Name,Phone No Etc With Edit,Delete Column In Grid View?

May 27, 2010

i have a grid view with some coulmns like Name,Phone no etc with Edit,Delete column in grid view. I click a row in grid view to Edit,it goes another page where i can edit all fields .Once i update i redirect the page to gridview. I want the grid view to remain in that particular page say 4 of the grid view

View 5 Replies

Forms Data Controls :: Custom Grid View Header - Grid View Row Created Event Versus Gridview Row Databound Events

Aug 24, 2010

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically behaviour of both the events in !Postback and page.Postback .

View 2 Replies

Forms Data Controls :: Click Button Outside Grid View And Display The Grid View Upon Load?

Feb 9, 2011

I am doing a online web application whereby user is able to enter in new template as well as search for template. The Add template is located outside the grid view and if user clicks on the button, it will load the grid view that is populated with data as there is a row of empty fields at the bottom. However when I click on the Add Template button, the grid view does not appear.

This is my business logic that I used it to search for records as well to click on the Add Template button to add in new records:

[Code]....

[Code]....

[Code]....

View 6 Replies

Forms Data Controls :: Extract Value In Grid View And Display It In A Textbox In Grid View ?

Jun 8, 2010

i have a grid view which displays only one value and i need to extract that value and display it in a textbox?

View 4 Replies

C# - How To Calculate Row-wise Sum Of Values In Grid-view And Display It In Grid View

Mar 14, 2011

I have a grid view which displays some values. now i have to calculate row wise sum of those values for each row and then display against them.i tried this code but i am getting error as Input String Was not in Correct Format.

public void gv_RowCreated(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int total = Convert.ToInt32(e.Row.Cells[1].Text) + Convert.ToInt32(e.Row.Cells[2].Text) + Convert.ToInt32(e.Row.Cells[3].Text) + Convert.ToInt32(e.Row.Cells[4].Text) + Convert.ToInt32(e.Row.Cells[5].Text) + Convert.ToInt32(e.Row.Cells[6].Text) + Convert.ToInt32(e.Row.Cells[7].Text);
((Label)gv.FindControl("Label8")).Text = Convert.ToString(total);
}
}

View 2 Replies

Forms Data Controls :: Force Grid View To Select Next Row On A Button_click Which Is Outside The Grid?

Jun 23, 2010

Have a GridView with a templated select button hidden and using

e.Row.Attributes.Add("onclick",Page.ClientScript.GetPostBackEventReference(this.grdMaster, "Select$" + e.Row.RowIndex.ToString())); to select a row .

When user like to update the datasource he will select one row from gridview then in selected indexchanged event i would display the selected row values beneath the form under the grid , Then user will update the contents displayed from grid and click an update button which is outside the grid . After updating the displayed row , i got to get the values of the next row in the grid and display them for next updation , i'e if users maually selects row 3 from grid then he can update the values using the update button and then on update click itself i'll have to display next row contents of row 4 and this process could go on .

View 3 Replies

How To Remove Grid Lines From Grid View Suing Style Sheet

Mar 31, 2010

how to remove grid lines from Grid View suing style sheet...

View 1 Replies

Linq To Xml Datasource For Grid View Is Not Working - The Grid Show No Rows

Jun 30, 2010

I'm getting some Xml back from a service. I would like it to be the datasource of a grid view on my aspx page. Here is a sample of the Xml

<?xml version="1.0" encoding="utf-16" ?>
<ArrayOfTripTollCompleteDC xmlns:xsi=[URL]"
xmlns:xsd=[URL]>
<TripTollCompleteDC>
<TripTollId>5</TripTollId>
<DMSLaneModeID xsi:nil="true" />
<HOVOnly>false</HOVOnly>
<CreateDateTime>2010-06-07T15:54:01.023</CreateDateTime>
<ConfigVTMSDelaySeconds>5</ConfigVTMSDelaySeconds>
</TripTollCompleteDC>

and here is my code that parses the xml and tries to bind the grid. What am I missing here?

var retVal = service.GetTripDetailsByTripID(tripId);
var xmlTrips = XDocument.Parse(retVal);
var tripTolls =
from t in xmlTrips.Elements("TripTollCompleteDC")
select new {
TripTollId = (int)t.Element("TripTollId")
, DMSLaneModeID = (int?)t.Element("DMSLaneModeID")
, HOVOnly = (bool)t.Element("HOVOnly")
, CreateDateTime = (DateTime)t.Element("CreateDateTime")
, ConfigVTMSDelaySeconds = (int)t.Element("ConfigVTMSDelaySeconds")
};
grdTripDetails.DataSource = tripTolls;
grdTripDetails.DataBind();

I realize these are anonymous types. Is that a problem? I have verified the service is returning the Xml as stated above. Can anyone out there point me in the right direction? Just for completeness, here is the grid markup <asp:GridView runat="server" ID="grdTripDetails" />

View 1 Replies

Forms Data Controls :: How To Edit Grid View (draged The Grid To The Aspx Page)

Sep 29, 2010

I have a grid view that does add, edit update and delete. ( I draged the grid to the aspx page ) it is working. I would like to have the following : once I lick on edit, I open a form inside the grid view to edit the fields. How can I do that.

View 4 Replies

Forms Data Controls :: Website Run Very Slow Using Tree View And Grid View

Sep 7, 2010

speed Performane i create a web site but it very slow run i use tree view and grid view but i do it run very fast

View 1 Replies

C# - Determining The Index Of Item In The List View Or Grid View When Using Paging

Oct 20, 2010

i have the following problem concerning the index::

my source code::

[Code]...

the problem is appeared when i have added the pager to my list view ,,i have out of range for index exception ... how to determine the page iam in and specify the right index either i use list view or grid view or other such controls..

View 1 Replies

Forms Data Controls :: View Record Through Hyperlink In Grid View?

Feb 9, 2011

i have gridview , it contains record of productsname field of product table and hyper link, hyperlink named as Detail.

when i click Detail link ,it will show record of that row in another page,means it shows complete fields of table in another page,,

i want to know only that,how detail link will perform,to view only that row record,

View 3 Replies

Forms Data Controls :: Search According To Id Or Case No Then View It In A Grid View?

Aug 19, 2010

i'm tring to search my table according to id number or the case number then view it in a gridviewbut it work for the first time then after it stop for error

Dim conn As New SqlConnection
conn.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATATask.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

[code]...

View 3 Replies

AJAX :: Update Panel Use In Tree View And Grid View?

Oct 29, 2010

how to asp.net update panel use in Tree view and grid view

View 2 Replies

Tree View Search Grid View Using Jquery Ajex?

Sep 9, 2010

i create a tree view and grid view how to search select node grid view show using jquery ajex

Tree Viwe Search Grid View using Jquery Ajex

View 2 Replies

Forms Data Controls :: Show View In Grid View?

Jun 8, 2010

i have created a simple view, and display it into gridview.. i have successfully created view but it is not shown in grid view , it return nothing...

protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=E:
arenHDI-AJAX-TK-Calendar-CSApp_DataDatabase.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("select * from nview", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}

View 3 Replies

Asp.net - Grid View - View State For Nested Controls?

Jul 14, 2010

I have a grid view with a nested text box in it.I would like to turn view state off but the fact of the matter is when data is posted,the text boxes inside the gridview aren't available (there are no rows in the gridview on postback). Control's information is not stored in the View State (for things like selected value and .text etc.):Control state,introduced in ASP.NET version 2.0, is similar to view state but functionally independent of view state.However,control state cannot be disabled. Control state is designed for storing a control's essential data (such as a pager control's page number) that must be available on postback to enable the control to function even when view state has been disabled. Source: http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx

View 2 Replies

Getting SQLDataSource Update Paramater From Gridview?

Mar 28, 2011

I am trying to get a parameter for my update from the gridview but it is an ID column that I do not want displayed. If I display the data in a boundfield it works fine but if I set the visibility to false the parameter is no longer sent to the update stored procedure. There does not appear to be a hiddenfield column that I can put into the gridview.I have tried to set the parameters through the code behind but I am not certain on how to access the data I want the following code does not work (It sets the parameter to nothing

Protected Sub grvFacilityDisciplineBillingRate_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles grvFacilityDisciplineBillingRate.RowUpdating
Dim row As GridViewRow = grvFacilityDisciplineBillingRate.Rows(e.RowIndex)[code]...

And this is the front end with the two ID columns displayed, which is not what I want

<asp:SqlDataSource ID="sqlDisciplineBillingRate" runat="server" DataSourceMode="DataSet" SelectCommandType="StoredProcedure" SelectCommand="SP_Facility_DisciplineBillingRates" UpdateCommandType="StoredProcedure" UpdateCommand="SP_DiscplineBillingRate_Update" ConnectionString="<%$ ConnectionStrings:Trustaff_ESig2 %>">[code]....

View 2 Replies

MVC :: Dynamically Constructing A Table Of Results?

Sep 6, 2010

I need to implement a search page where a user will be able to specify some search criteria and perform a search. It's a requirement that the results are displayed on the same page, beneath the search criteria.

Here's the code for the controller class:

[Code]....

For simplicity, the table string above is hard coded but would be constructed dynamically in the real code.
I also have the following form defined In the body of my html:

[Code]....

Finally, I'm using JQuery to hijack the submission of the form and to request the html for the table:

<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("form[action$='GetTableData']").submit(function() {
$.post($(this).attr("action"), $(this).serialize(), function(response) {
$("#tablePanel").html(response);
});
return false;
});
})
</script>

I'm fairly new to ASP.NET and MVC but the thing that slightly bothers me is that the html is generated in the code-behind for the view.

View 3 Replies

Passing Multidementional Array As Paramater In Method?

Sep 10, 2010

i want to pass multidementional array as parameter, below the code i worked, is it right

class ASRateContract
{
public string[,] standardrate = new string[3,2];
public string[,] storagerate = new string[3,3];
public void setstandardrate( string [3,2]name )
{
standardrate = name;
}
public string setstoragerate()
{
return "";
}
public string getstandardrate()
{
return standardrate;
}

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved