Click here to Skip to main content
15,889,462 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to make the content Fixed [modified] Pin
msqar27-Mar-11 13:04
msqar27-Mar-11 13:04 
GeneralRe: How to make the content Fixed Pin
the exile27-Mar-11 22:28
the exile27-Mar-11 22:28 
GeneralRe: How to make the content Fixed Pin
msqar28-Mar-11 1:16
msqar28-Mar-11 1:16 
AnswerRe: How to make the content Fixed Pin
Dalek Dave26-Mar-11 7:21
professionalDalek Dave26-Mar-11 7:21 
GeneralRe: How to make the content Fixed Pin
the exile26-Mar-11 22:31
the exile26-Mar-11 22:31 
Questionnand_bca@rediffmail.com Pin
Nand Kishor Chaudhary26-Mar-11 3:43
Nand Kishor Chaudhary26-Mar-11 3:43 
AnswerRe: change your subject Pin
Ravi Sant26-Mar-11 6:36
Ravi Sant26-Mar-11 6:36 
QuestionProblem updating DetailsView when added DropDownList Pin
kbalias24-Mar-11 23:39
kbalias24-Mar-11 23:39 
Hi
I am struggling with updating data from a web page. On the page I have a DetailsView control which is bound to a table in the SQL Server database. I have enabled Editing.

One of the fields in the table is a foreign key to a lookup table (for the Referring Hospital) in the database. I would like to have a DropdownList in the DetailsView so that the user can choose the item.


I have changed the field to a TemplateField and while the field (“HospID”) is still a TextBox the update to database works. For example when I change the LastName and click ‘Update’, the update reflects in the database.

Here is the markup:

<asp:TemplateField HeaderText="HospID" SortExpression="HospID">
    <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("HospID") %>'></asp:TextBox>
    </EditItemTemplate>
    <InsertItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("HospID") %>'></asp:TextBox>
    </InsertItemTemplate>
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("HospID") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="LastName" HeaderText="LastName" 
    SortExpression="LastName" />


However when I replace the TextBox in the EditTemplate with a DropdownList and try to update, the changes do not reflect in the database. Even if I have just changed the LastName.

The markup for the DropdownList is as follows:

<asp:TemplateField HeaderText="HospID" SortExpression="HospID">
    <EditItemTemplate>
        <asp:DropDownList ID="DropDownList1" runat="server" 
                DataSourceID="SqlDataSource_RefHosp" DataTextField="HospShort" 
                DataValueField="HospID">
            </asp:DropDownList>                
    </EditItemTemplate>
    <InsertItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("HospID") %>'></asp:TextBox>
    </InsertItemTemplate>
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("HospID") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>



Even if I just use a basic DropdownList with no databinding the update does not work.

<asp:DropDownList ID="DropDownList_RefHosp" runat="server" 
    DataTextField="HospShort" DataValueField="HospID">
</asp:DropDownList>



I am stumped here so if anybody can give me some pointers it will be appreciated.

Regards.

Kobus
AnswerRe: Problem updating DetailsView when added DropDownList Pin
Cnu5555526-Mar-11 2:15
Cnu5555526-Mar-11 2:15 
Questionhow to copy row from one gridview to another,each time a new row is added........ Pin
Seema Rayat24-Mar-11 22:02
Seema Rayat24-Mar-11 22:02 
AnswerRe: how to copy row from one gridview to another,each time a new row is added........ Pin
Not Active25-Mar-11 1:23
mentorNot Active25-Mar-11 1:23 
GeneralRe: how to copy row from one radgrid to another,each time a new row is added........ Pin
Seema Rayat25-Mar-11 1:30
Seema Rayat25-Mar-11 1:30 
GeneralRe: how to copy row from one radgrid to another,each time a new row is added........ Pin
Not Active25-Mar-11 2:22
mentorNot Active25-Mar-11 2:22 
QuestionHow can i input "&" in the html code? Pin
buffering8324-Mar-11 15:13
buffering8324-Mar-11 15:13 
AnswerRe: How can i input "&" in the html code? Pin
GlobX24-Mar-11 15:52
GlobX24-Mar-11 15:52 
GeneralRe: How can i input "&" in the html code? Pin
Pravin Patil, Mumbai25-Mar-11 2:04
Pravin Patil, Mumbai25-Mar-11 2:04 
AnswerRe: How can i input "&" in the html code? Pin
Dalek Dave26-Mar-11 3:39
professionalDalek Dave26-Mar-11 3:39 
Questionfile download in mvc 2.0 Pin
rudra prasanna biswal24-Mar-11 11:45
rudra prasanna biswal24-Mar-11 11:45 
QuestionDataList web user control Pin
De_Novice24-Mar-11 6:12
De_Novice24-Mar-11 6:12 
AnswerRe: DataList web user control Pin
Sandeep Mewara26-Mar-11 21:46
mveSandeep Mewara26-Mar-11 21:46 
QuestionLog messages in event viewer Pin
berba24-Mar-11 0:24
berba24-Mar-11 0:24 
AnswerRe: Log messages in event viewer Pin
Pete O'Hanlon24-Mar-11 3:28
mvePete O'Hanlon24-Mar-11 3:28 
QuestionSSRS page break problem Pin
rahul.net1123-Mar-11 23:49
rahul.net1123-Mar-11 23:49 
AnswerRe: SSRS page break problem Pin
Sandeep Mewara26-Mar-11 21:45
mveSandeep Mewara26-Mar-11 21:45 
Questionregular expression validator Pin
Satish_S23-Mar-11 21:21
Satish_S23-Mar-11 21:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.