Click here to Skip to main content
15,914,444 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to prevent user click back button after log out? Pin
John-ph16-Oct-07 23:25
John-ph16-Oct-07 23:25 
AnswerRe: How to prevent user click back button after log out? Pin
varshavmane16-Oct-07 23:32
varshavmane16-Oct-07 23:32 
AnswerRe: How to prevent user click back button after log out? Pin
Sandeep Kumar17-Oct-07 0:13
Sandeep Kumar17-Oct-07 0:13 
AnswerRe: How to prevent user click back button after log out? Pin
bug_aonz17-Oct-07 16:22
bug_aonz17-Oct-07 16:22 
QuestionInstallation help...... Pin
SUDHAKAR PALLAM16-Oct-07 22:57
SUDHAKAR PALLAM16-Oct-07 22:57 
AnswerRe: Installation help...... Pin
Sandeep Kumar17-Oct-07 0:16
Sandeep Kumar17-Oct-07 0:16 
QuestionAccessing FTP and display the folder structure Pin
Wesley Samuel16-Oct-07 22:42
Wesley Samuel16-Oct-07 22:42 
QuestionHow to programmatically bind the dropdownlist in gridview's edititemtemplate? Pin
stroberi16-Oct-07 22:41
stroberi16-Oct-07 22:41 
Hi,
I have a gridview, I use a dropdownlist as edititemtemplate.
I don't wanna use SQLDataSource as the datasource for the dropdownlist. I use coding in code-behind page.

I get a problem, when button edit clicked, how to properly bind the data for the dropdownlist at the right time, just for the row clicked?

I've used gridview.rowdatabound event, but i have a problem because the checking proccess when i click the edit button gives error because it goes to gridview1.databind in gridview1.rowediting event before it enters the right row (the row that should be in edit mode).

Please help me check what's wrong, what the solution is... Thank you very much before and after.

Here is my code for rowdatabound and rowediting :

<br />
Protected Sub gridExpenses_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridExpenses.RowDataBound<br />
        Dim conn As New SqlConnection<br />
        Dim cmd As New SqlCommand<br />
        Dim da As New SqlDataAdapter<br />
        Dim ds As New DataSet<br />
        Dim dt As New DataTable<br />
        Dim conString As String<br />
        Dim rdr As SqlDataReader<br />
        Dim row As GridViewRow = e.Row<br />
        Dim i As Integer = row.RowIndex<br />
        <br />
        conString = System.Configuration.ConfigurationManager.AppSettings("connString")<br />
        conn = New SqlConnection(conString)<br />
<br />
        If (row.RowType = DataControlRowType.DataRow) Then<br />
            'If (row.RowState = DataControlRowState.Edit) Then<br />
            If row.RowState = DataControlRowState.Edit OrElse row.RowState = (DataControlRowState.Edit Or DataControlRowState.Alternate) Then<br />
                Dim cmcd As DropDownList = CType(row.FindControl("comboCmcd2"), DropDownList)<br />
                conn.Open()<br />
                cmd = conn.CreateCommand<br />
                cmd.CommandText = "SELECT mcom_idno, mcom_cmnm FROM tbl_mcom"<br />
                rdr = cmd.ExecuteReader<br />
                cmcd.DataSource = rdr<br />
                cmcd.DataBind()<br />
                cmcd.SelectedIndex = 0<br />
                conn.Close()<br />
            End If<br />
        End If<br />
    End Sub<br />
<br />
    Protected Sub gridExpenses_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gridExpenses.RowEditing<br />
        Dim conn As New SqlConnection<br />
        Dim cmd As New SqlCommand<br />
        Dim cmd2 As New SqlCommand<br />
        Dim da As New SqlDataAdapter<br />
        Dim ds As New DataSet<br />
        Dim dt As New DataTable<br />
        Dim conString As String<br />
<br />
        conString = System.Configuration.ConfigurationManager.AppSettings("connString")<br />
        conn = New SqlConnection(conString)<br />
<br />
        gridExpenses.EditIndex = e.NewEditIndex<br />
<br />
        conn.Open()<br />
        cmd = conn.CreateCommand<br />
        cmd.CommandText = "SELECT e.mexp_idno, e.mexp_mnth, e.mexp_year, e.mexp_amnt, e.mexp_cmid, c.mcom_cmnm FROM tbl_mexp e, tbl_mcom c WHERE e.mexp_cmid = c.mcom_idno"<br />
        da.SelectCommand = cmd<br />
        da.Fill(ds, "mexp")<br />
        dt = ds.Tables("mexp")<br />
        gridExpenses.DataSource = ds.Tables("mexp").DefaultView<br />
        gridExpenses.DataBind()<br />
    End Sub<br />


This is my code for the dropdownlist as edititemtemplate :
<br />
<EditItemTemplate><br />
                                                                                                                        <asp:DropDownList ID="comboCmcd2" runat="server" DataTextField="mcom_cmnm"<br />
                                                                                                                            DataValueField="mexp_cmid" SelectedValue = '<%# Bind("mexp_cmid") %>'><br />
                                                                                                                        </asp:DropDownList><br />
                                                                                                                    </EditItemTemplate><br />

QuestionError Deleting File or Folder Pin
pavya_Cool16-Oct-07 22:31
pavya_Cool16-Oct-07 22:31 
AnswerRe: Error Deleting File or Folder Pin
Sandeep Akhare16-Oct-07 22:42
Sandeep Akhare16-Oct-07 22:42 
AnswerRe: Error Deleting File or Folder Pin
N a v a n e e t h16-Oct-07 22:48
N a v a n e e t h16-Oct-07 22:48 
QuestionClick Browsers Button Display the Message [modified] Pin
Rinki Mukheraji16-Oct-07 22:20
Rinki Mukheraji16-Oct-07 22:20 
AnswerRe: Click Browsers Button Display the Message Pin
Pete O'Hanlon17-Oct-07 1:32
mvePete O'Hanlon17-Oct-07 1:32 
QuestionInsertion Method Pin
BasharatAli16-Oct-07 22:06
BasharatAli16-Oct-07 22:06 
AnswerRe: Insertion Method Pin
Guffa16-Oct-07 22:17
Guffa16-Oct-07 22:17 
GeneralRe: Insertion Method Pin
BasharatAli16-Oct-07 22:58
BasharatAli16-Oct-07 22:58 
GeneralRe: Insertion Method Pin
Pete O'Hanlon17-Oct-07 1:33
mvePete O'Hanlon17-Oct-07 1:33 
Questionplease help Pin
Sonia Gupta16-Oct-07 21:29
Sonia Gupta16-Oct-07 21:29 
AnswerRe: please help Pin
Pete O'Hanlon16-Oct-07 22:19
mvePete O'Hanlon16-Oct-07 22:19 
GeneralRe: please help Pin
N a v a n e e t h16-Oct-07 22:31
N a v a n e e t h16-Oct-07 22:31 
GeneralRe: please help Pin
Pete O'Hanlon16-Oct-07 22:59
mvePete O'Hanlon16-Oct-07 22:59 
AnswerRe: please help Pin
Guffa16-Oct-07 22:33
Guffa16-Oct-07 22:33 
QuestionHow to prevent user enter directory list? Pin
bug_aonz16-Oct-07 21:13
bug_aonz16-Oct-07 21:13 
AnswerRe: How to prevent user enter directory list? Pin
N a v a n e e t h16-Oct-07 21:16
N a v a n e e t h16-Oct-07 21:16 
GeneralRe: How to prevent user enter directory list? Pin
bug_aonz16-Oct-07 21:34
bug_aonz16-Oct-07 21:34 

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.