I have a table which I store encrypted data in it.
I use sqldatasource to do the CRUD.
I need to decrypt whole data in selecting event of sqldatasource, like this:
protected void sqldatasource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if(Columnname="col1")
{
MeyDecryptMethod."col1".ToString();
}
}
please tell me if it is possible to do it this way or not, and how.
Thanks
PS: please do not suggest other ways. because in this scenario only this method is possible.
Selecting event rise starting select, so you cannot access data in this event, event details are here.
Related
Currently i am using Devexpress XtraReports V11.2.8. My problem is i am able to populate report in V11.1.6 but i am unable to populate report in V11.2.8 it showing only scroll bar in the reportviewer when i debug it is properly mapping and binding the data. FYI: I need to bind/Initialize reportviewer in button click only. Devexpress people said that i need to initialize reportviewer with the report in page_load it self but we can't do that because we have large amount of data exist and we need to populate report with particular input criteria matched result only. Please advice.
FYI: refer this link for devexpress response on the above issue http://www.devexpress.com/Support/Center/Issues/ViewIssue.aspx?issueid=Q362696
I can't find any solution about version problem without additional information.
but, the 2nd problem you told, i can give a possible solution to that. You can take necessary input you need for the report and then click on the button to preview the report regarding on inputs. It is better to create a stored procedure in your database for this report.
Suppose, you need to show a report for specific 'Cust_Id'. In the 'Form1' put a text field for 'Cust_Id' and a 'button'. On button click event put the following code,
private void simpleButton1_Click(object sender, EventArgs e)
{
Portfolio_XtraReport port = new Portfolio_XtraReport();
string custID = textEdit1.Text.ToString();
port.Portfolio(custID);
port.ShowPreview();
}
now in the 'Portfolio_XtraReport.cs' put the following code,
public Portfolio_XtraReport()
{
Portfolio("N");
}
public void Portfolio(string custId)
{
if (custId != "N")
{
InitializeComponent();
sP_PORTFOLIOTableAdapter.GetData(custId);
}
}
Here, sP_PORTFOLIOTableAdapter is the table adapter for the dataset, I used a stored procedure which takes 'Cust_Id' as input.
I created a table in sql database which has list of prices and Items Name....
I wrote a small coding to get the values of item names into my dropdownlist....
Now,
If i select an item in the dropdownlist, I need the price to displayed in the textbox or label... How can I do this? help me out!
There are several different ways of doing that.
You could
- load price/product as JS name value collection and do it client side - most efficient way
- populate dropdown with productId (value) and description and handle itemindexchanged event and do everything server side - not recommended for a public facing, busy web apps.
- send ajax call to web service to get price (client side) - that when you have a bit more complicated model.
It's up to you to decide.
Hope that helps.
Set the AutoPostback property of the DropDownBox to True
Then use something like this:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Value;
}
Take for example a DetailsView control with an ObjectDataSource as its datasource.
Normally in the DetailsView.ItemUpdated event I would grab a reference to the details view by casting the sender:
DetailsView dv = (DetailsView)sender;
In certain situations it becomes necessary to handle the event inside the ObjectDataSource.ItemUpdated event. In this case sender is now of type ObjectDataSource. What I want to be able to do is write clean code that isnt hardcoded like
Label label1 = DetailsView1.FindControl("Label1");
I looked over the documentation and also did some searches but couldnt find how I would write some code like the following:
protected void ObjectDataSource1_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
ObjectDataSource ods = (ObjectDataSource)sender;
DetailsView dv = (DetailsView)ods.SOMETHING_HERE;
}
Does anyone know what I should be putting in the SOMETHING_HERE in the snippet above?
That's happen because the "OnInserted" event is suppose to be an event examine the values of a return value or output parameters, or to determine whether an exception was thrown after an Insert operation has completed. The return value, output parameters, and exception handling properties are available from the ObjectDataSourceStatusEventArgs object that is associated with the event.
What you can do here is just call ObjectDataSource.select() that returns the view in this case but I don't think it's a good choice.
You should review you business logic and try to manage it somewhere it makes more sense
Anyway your code should look like the below:
ObjectDataSource ods = YourDataSource.select();
DetailsView dv = (DetailsView)ods;
Considering the example you provided, I don't think there is anything you can replace for Something_Here. It is the ODS linked to DV and not the other way. Also one DataSource can be linked to several DataBound Controls.
So as far as I know it is simply not possible.
I know the question has already been posted here but we didn't get to an real solution.
I have bound my ListView to an SqlDataSource and I want to write some text in a control present in the view created in the LayoutTemplate depending on some properties of the rows returned.
Obviously, I'm using the ItemDataBound event to feed my items but this is not the point.
The spontaneous solution was to bind the ListView.DataBound event and access the raw datasource (a DataTable?) and do the required calculations.
I inspected the Items property and, despite it was not empty, the related DataItem property was null.
Do you have any suggestion?
The only work-around I can come to is to execute the calculations in the ItemDataBound event and accumulate the result in some private fields. But it's really ugly to see and makes harder to get some of the required values.
Thanks a lot.
In the ItemDataBound you should be able to access the data source for the Listview through the DataSource property (you might need to cast it to a DataTable):
protected void Listview1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
DataTable sourceData;
sourceData = (DataTable)Listview1.DataSource;
// sourceData is a DataTable, you can run .Compute or whatever you need
}
I am new to asp.net and know little bit about its working and as I am moving forward I am getting new and more newer doubts.
Here at this point I was working with two RadioLists that are being binded at page load.
Now when a user changes the index of radio button in list 1. Second needs to get updated accordingly depending what value is currently set for selected radio button.
Since the page will be posted back hence I either need to fire a query again to get new data from DataBase for currently selected index or can store 2-3 tables in session in form of Dataset.
What should I do in such scenario. Should I fire an sql query again or retrieve DataSet from Session.
What is the most optimal approach for this. And WHY ?
The data for radio button list 1 (rbl1) should not be retrieved again from the database. It should already be populate from the ViewState. This is an invisible object on your page that keeps track of the contents of your controls between loading them into the browser and returning the form back to the server. If you rebind rbl1 to the data on a postback, you will lose the current selection.
There should be nothing wrong with retrieving the data for the send radiobuttonlist from the database if the results are going to change depending on the selection of the first.
However, if the size of the data is small you might want to cache the results to the application cache, if all users see the same set of data, or the session cache if it is user-dependent.
Then you can use Linq to query the data based on the selection from the first radiobuttonlist.
<asp:RadioButtonList ID="rbl1" runat="server" AutoPostBack = "true"
OnSelectedIndexChanged="rbl1_SelectedIndexChanged">
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//bind your rbl1 here
}
}
protected void rbl1_SelectedIndexChanged(object sender, EventArgs e)
{
//load your second radio button list depending on the selection of the first
}