|
Hi am using DetailsView and ObjectDataSource to insert records in database.
detailsview contains dropdown,texbox and Listbox controls.. I selected multiple items from Listbox and now if I click on Insert button multiple records has to be inserted in database. Is this possible...? can u send me the code how can I approach? pls see the following code..
while trying to put code for listbox it is inserting last record only...
// Code behind file
protected void DVDoctorActivity_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
if (Page.IsValid)
{
string strDoctor = ((DropDownList)((DetailsView)sender).FindControl("ddlInsDoctor")).SelectedValue;
e.Values["DoctorId"] = strDoctor;
e.Cancel = false;
}
foreach (ListItem listitem in ((ListBox)((DetailsView)sender).FindControl("lbProducts")).Items) // it is inserting only one record.. (last selected item)
{
if (listitem.Selected)
{
string strProductId = ((DropDownList)((DetailsView)sender).FindControl("ddlInsDoctor")).SelectedValue;
e.Values["ProductId"] = Convert.ToInt32(strDoctorId);
}
else e.Cancel = true;
}
// aspx file..
<asp:DetailsView ID="DetailsView1" runat="server" SkinID="DetailsView" DataKeyNames="DoctorActivityId"
DataSourceID="DoctorActivityDataSource" AutoGenerateRows="False" OnItemInserting="DVDoctorActivity_ItemInserting">
<Fields>
<asp:TemplateField>
<InsertItemTemplate>
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
<table>
<tr>
<td style="width: 113px; height: 21px;">
Doctor </td>
<td style="height: 21px">
<asp:DropDownList ID="ddlInsDoctor" runat="server" DataSourceID="DVDoctorMasterDataSource"
DataTextField="DoctorName" DataValueField="DoctorId">
</asp:DropDownList><asp:ObjectDataSource ID="DVDoctorMasterDataSource" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDoctors" TypeName="ActNexxt.ActNexxtDataSetTableAdapters.Doctor_MasterTableAdapter">
</asp:ObjectDataSource>
</td>
</tr>
<tr>
<td style="width: 113px">
</td>
<td>
<asp:TextBox ID="txtEdtEmpId" Visible="false" runat="server" Text='<%# Bind("EmployeeId") %>'></asp:TextBox> </td>
</tr>
<tr>
<td>
<asp:ListBox ID="lbProducts" runat="server"></asp:ListBox>
<asp:ObjectDataSource ID="CampaignDrugSource" runat="server"
InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetProductsByCampaignId"
TypeName="ActNexxt.ActNexxtDataSetTableAdapters.Campaign_DrugTableAdapter" >
>/td>
</tr>
</table>
</asp:Panel>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:Button ID="Button1" runat="server" CommandName="Update" Text="Update" SkinID="Button" />
<asp:Button ID="Button2" runat="server" CommandName="Cancel" Text="Cancel" SkinID="Button"
CausesValidation="false" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Insert" SkinID="Button" />
<asp:Button ID="Button2" runat="server" CommandName="Cancel" Text="Cancel" SkinID="Button"
CausesValidation="false" />
</InsertItemTemplate>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CommandName="New" Text="New" SkinID="Button" />
<asp:Button ID="Button2" runat="server" CommandName="Edit" Text="Edit" SkinID="Button" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Fields>
</asp:DetailsView>
thanks..
|
|
|
|
|
Hi friends,
Please give me some details reg. good book for asp.net for beginners.
Thanks in Advance.
Regards,
Prya
|
|
|
|
|
Wrox Publication books will good.
Regards,
Satips.
|
|
|
|
|
this is the situation.
i use form authentification as below
<authentication mode="Forms">
<forms name=".EHR_COOKIE" loginUrl="/EHR.WebUI/LoginForm.aspx" protection="All" timeout="180" path="/"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
so no one can get through my system without login through LoginForm.aspx.
let's say A person logged in through the LoginForm.aspx and then there is a menu on the top that will popup another browser so that A person can log in with different account.(we need this function because the client required) But as you know if A open a window from the logged in page, it will share sessions even though it looks like A has two different accounts with two diffent browses. The sessions will mix.
Does anybody know how can i separate the two accounts?
I know that it will be totally simple if A person log in and if he wants to log in with different account just click on iexplore icon and log in again. i mean this can be another solution if i can have two form authentification. <-- but i couldn't find the way.
anybody help..please...
-- modified at 21:43 Sunday 1st April, 2007
|
|
|
|
|
I use Css to apply to my lable control and it work well in design mode:
http://i2.photobucket.com/albums/y26/rockxuyenmandem/1-1.jpg
However when i view this page in browser Css doesn't apply changes:
http://i2.photobucket.com/albums/y26/rockxuyenmandem/2-3.jpg
Could someone give me the reason, thanks so much
|
|
|
|
|
Anyone have any suggestions on a software application to stress test an ASP.NET web application?
|
|
|
|
|
hello,
How can I create a new row in a grid view.
Thanks.
Dad
|
|
|
|
|
You cannot add new row directly to the GridView. But you can add new row indirectly.
Add a new Row in the DataSet which you assign to the GridView DataSource.
|
|
|
|
|
Hai,
when i am saving data through stored procedure the following error is coming i am not able to find where i have to change,
Description is below,
Thanks and Regards,
surendra
System.Data.SqlClient.SqlException: Unclosed quotation mark before the character string ','2','1')'. Line 1: Incorrect syntax near ','2','1')'. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at NS.clinicalhistorygrid.NS_CLINICALHIST_MST_sp(String PARAMMYOPTION, DateTime PARAMCLINICHIST_DATE, String PARAMCLINICHIST_TIME, String PARAMSPECIALTY, Int32 PARAMCLINICHIST_ID, String PARAMPAT_REG_NO, String PARAMSTATUS, Int32 PARAMRELATION_PATIENT_ID, String PARAMGIVEN_BY, String PARAMCONSULTANT, String PARAMPRESENT_HISTORY, String PARAMTAKEN_BY, Int32 PARAMRETVAL) in C:\Inetpub\wwwroot\NS\clinicalhistory.aspx.vb:line 1681
surendra
|
|
|
|
|
This error means that you have ' somewhere in the middle of a column you are trying to save. Like if you are saving the person's name and their name is "o'neil" that would blow up. So you might need to check your strings for ' and either remove them or replace them with a " or something like that.
Hope that helps.
Ben
|
|
|
|
|
Hii,
i have one issue that i couldn't solve it, maybe anyone can help me:
i use disconnect datset to work with my data source.
i have 2 tables, one is visitors and another one is orders, the relation between these tables is an id field which is an increment field.
visitor can enter to the website, fill his details and order something.
first step i fill his details in a new row in the database.
now i want to fill a row of his order in orders table, there i have to set his id but i dont know the id because i have just update the visitors table and his id is automaticlly assigned, what can i do...
any help is HELP.
|
|
|
|
|
What Database do you use?
How do you insert the visitor record?
In SQL Server you can use scope_identity() function to return the last inserted identity.
|
|
|
|
|
If you use SQL Server, you can use @@IDENTITY to get the Last inserted identity value. To use this you have form the querys in a batch and then you have execute it.
Eg:
sQuery = "DECLARE @MyID AS INT"<br />
sQuery &= " INSERT INTO PrimaryTable (....) VALUES (....)"<br />
SQuery &=" SET @MyID=@@IDENTITY"<br />
SQuery &=" INSERT INTO SecondaryTable (...) VALUES (..@MyId...)"<br />
<br />
Com.CommandText = sQuery<br />
Com.ExecuteNonQuery
|
|
|
|
|
Hello,
How to handle events of Usercontrol(containing dropdownlist on .ascx page) on .aspx page.I am having a button on .aspx page.When I click on button ,i want to retrieve the value of selected dropdownlist item.I have used LoadControl() method to loasd the usercontrol on .aspx page.If possible try to explain me with example.
thanks,
aekta
|
|
|
|
|
In the usercontrol expose the selectedValue of the dropdownlist in a Public property on the UserControl. That way in the aspx page you can just do:
userControl.Publicproperty where userControl is the name of your UserControl variable and Publicproperty is what you named the SelectedValue of the Dropdown. The PublicProperty would probably be readonly with only a Get that points to dropdownlist.SelectedValue.
Hope that helps.
Ben
|
|
|
|
|
Hi there,
I'm writing a web application which extensively uses the Cache. Now I'd like to get an overview over all cached objects and their sizes in bytes. Does anyone know how to retrieve the size of an object in memory?
So far I've googled but didn't come up with something useful. Most answers were like 'you can't get the size...'. Btw, I'm using .net 1.1.
If it is not possible, is there a way to get the amount of memory the Cache is using altogether?
Any help is greatly appreceated.
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
Hi,
I am most likely doing something wrong that's really stupid and simple, but if anyone can help I will be very grateful.
I made a DataList with an SqlDataSource and FormView (with a label in) inside it. I used FindControl to get to the SqlDataSource and FormView to alter their properties, but when I do the same for the Label inside the FormView it just comes back with an error: "Object reference not set to an instance of an object."
The code I have is:
<pre>
Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs) Handles DataList1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or ListItemType.AlternatingItem Then
Dim FormView1 As FormView = CType(e.Item.FindControl("FormView1"), FormView)
FormView1.Visible = True
'This part works alrigh (I think)
'I must have made an error in the following code.
If FormView1.CurrentMode = FormViewMode.ReadOnly Then
Dim LabelRating As Label = CType(FormView1.Row.FindControl("lblRating"), Label)
Response.Write(LabelRating.Text.ToString)
End If
End If
End Sub
</pre>
I'm really sorry to be annoying, but I would really appreciate some help with this one.
Thank you!
Jack.
|
|
|
|
|
hi..
i am trying to add a drop down list value to the database.. the error comes is.. incorrect syntax near 'itemname'..
cmd2.CommandText = "Insert into Bill(BillNo,PatID,Test,TstCateg) Values('"+maxlbl.Text+"','" + patid.Text + "','" +DropDownList2.SelectedItem.Value+ "','"+DropDownList1.SelectedItem.Value+"' ";<br />
<br />
and just for the record.. it had worked previously.. in another app...
Kunal
|
|
|
|
|
check for datatype..
Thanks,
Sun Rays
|
|
|
|
|
Help me to know the answer......
A.R.Prabhakaran
|
|
|
|
|
Hi there!
SQL Client is a client which only works with MS SQL server. Whereas the Oracle Client works only with the Oracle Database.
The OLEDB client works with any new database including MS SQL, Oracle etc,.
But if you are using MS SQL server, it's advisable to use the SQL client, Because this makes thing faster.
Hope that helps......
You don't have to be AFRAID!
|
|
|
|
|
what is the difference between datagrid,datarepeater and datalist?
chanthini prabhakaran
|
|
|
|
|
The main differnces between DataGrid(GridView ASP.NET 2.0), Repeater, and DataList are following:
1)Repeater control is lookless, which means you have to provide template for look.
2) DataList displays either a columnar or normal HTML flow layout. It also supports for selection, editing, and editing of items. (Repeater does not).
3)DataGrid sorting, paging which other control does not. It also support select/Edit/Delete.
4) You can use TemplateColumn in DataGrid. By far, DataGrid is a handy control for most ASP.NET developer.
Sanjeev
|
|
|
|
|
hi,
datagrid displays datasource as a html table format mean each datafield is represented as single column, but with datalist it depends on repeatColumn attribute.
datalist by default does not support pagaing , sorting
repeater is used for representing datasorce in non table format like
countries
i hope this some idea about datacontrols,
|
|
|
|
|
DataList is just like DataRepeater but with additional functionalities.
and additinal templates for formating.We can have custom paging inDataList. But no in bulit paging But where as in DataGrid there isin built paging ,sorting,editiong,which reduces lot of cod e on developer. Its better to use repater control if performance only the criteria.
Since Grid and Lsit Takes round trip than Repeater .
Features of Datagrid
(1)Displays data as a table
(2)Control over
(3)Alternate item
(4)Header
(5)Footer
(6)Colors, font, borders, etc.
(7)Paging
(8)Updateable
(9)Item as row
Features of Repeater
•List format
•No default output
•More control
•More complexity
•Item as row
•Not updateable
Features of DataList
•Directional rendering
•Good for columns
•Item as cell
•Alternate item
•Updateable
Regards,
Satips.
|
|
|
|