Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ข้อมูลเมื่อกด Edit ของ Dropdownlist และ RadiobuttonList in Gridview ไม่แสดงค่าปัจจุบัน (ยังไม่ได้คำตอบเลยค่ะ)



 

ข้อมูลเมื่อกด Edit ของ Dropdownlist และ RadiobuttonList in Gridview ไม่แสดงค่าปัจจุบัน (ยังไม่ได้คำตอบเลยค่ะ)

 



Topic : 119629



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์




อันนี้คือรูปตัวอย่างข้อมูลใน Gridview จะเห็นว่า ST04 และเป็นคำว่าปิดร้าน

ex1

แต่พอกด Edit เพื่อทำการแก้ไขข้อมูลใน Gridview จะแสดงค่าตรง DDL ที่ควรจะเป็นค่า ST04 ดันกลายเป็นค่า default ที่ ST01 (ร้านที่1) และ RBL ไปเซ็ทค่า default ตรงเปิดร้านแทน

ex2

แบบนี้ควรจะแก้ไขยังไงดีค่ะ ขอคำแนะนำหน่อยค่ะ



Tag : .NET, Web (ASP.NET), VB.NET









ประวัติการแก้ไข
2015-10-30 08:22:54
2015-10-30 09:00:57
2015-10-30 09:09:07
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-10-29 14:52:37 By : heaunn View : 1126 Reply : 12
 

 

No. 1



โพสกระทู้ ( 4,434 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ต้องดูที่โค้ดอ่าครับ
เขาว่าไงมั่ง






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-29 15:23:42 By : lamaka.tor
 


 

No. 2



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.IO
Imports System.Drawing
Imports System.Web.UI.WebControls.Image

Public Class Food1
    Inherits System.Web.UI.Page

    Dim con As String = ConfigurationManager.ConnectionStrings("con").ConnectionString
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            DropdownlistStore()
            buttonSave.Attributes.Add("onclick", "return confirm('คุณต้องการบันทึกใช่หรือไม่?');")
            loadStoreFood()
        End If
    End Sub

    Protected Sub loadStoreFood()
        Dim SqlCon As New SqlConnection(con)
        SqlCon.Open()
        Dim cmd As New SqlCommand("SELECT rkey,storeID,foodName,foodDetails,unitPrice,statusonline,foodPic FROM StoreFood", SqlCon)
        Dim da As New SqlDataAdapter(cmd)
        Dim ds As New DataSet()
        da.Fill(ds)
        Dim count As Integer = ds.Tables(0).Rows.Count
        SqlCon.Close()

        If ds.Tables(0).Rows.Count > 0 Then
            gridStoreFood.DataSource = ds
            gridStoreFood.DataBind()
        Else
            ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
            gridStoreFood.DataSource = ds
            gridStoreFood.DataBind()
            Dim columcount As Integer = gridStoreFood.Rows(0).Cells.Count
        End If
    End Sub

    '*** DROPDOWNLIST STORES ***'
    Function DropdownlistStore() As DataTable
        Dim strSQL As String
        Dim da As SqlDataAdapter
        Dim dt As New DataTable
        Dim sqlCon As New SqlConnection(con)
        sqlCon.Open()
        strSQL = "SELECT storeID,storeName FROM Store"

        da = New SqlDataAdapter(strSQL, sqlCon)
        da.Fill(dt)
        da = Nothing
        sqlCon.Close()

        With ddlstore1
            .DataSource = dt
            .DataTextField = "storeName"
            .DataValueField = "storeID"
            .DataBind()
            .Items.Insert(0, New ListItem("--- กรุณาเลือกร้านอาหาร ---", "0"))
        End With

        ddlstore1.SelectedIndex = ddlstore1.Items.IndexOf(ddlstore1.Items.FindByValue("0"))

        Return dt
    End Function

    Protected Sub buttonSave_click(sender As Object, e As ImageClickEventArgs) Handles buttonSave.Click
        '*** UPLOAD PICTURE ***'
        If fiUpload.HasFile Then

            Dim intWidth, intHeight As Integer
            Dim UlFileName As String

            intWidth = 120 '*** Fix Width ***'
            'intHright = 0 '*** If = 0 Auto Re-cal Size
            intHeight = 120

            UlFileName = "Image_Food/" & fiUpload.FileName

            '*** SAVE IMAGE ***'
            fiUpload.SaveAs(Server.MapPath(UlFileName))

            Dim objGraphic As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(UlFileName))
            Dim objBitmap As Bitmap

            '*** CALCULATE HEIGHT ***'
            If intHeight > 0 Then
                objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
            Else
                If objGraphic.Width > intWidth Then
                    Dim ratio As Double = objGraphic.Height / objGraphic.Width
                    intHeight = ratio * intWidth
                    objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
                Else
                    objBitmap = New Bitmap(objGraphic)
                End If
            End If
            objGraphic.Dispose()
            objBitmap = Nothing
            objGraphic = Nothing

            '*** INSERT ***'
            Dim SqlCon As New SqlConnection(con)
            Dim cmd As New SqlCommand()
            SqlCon.Open()
            cmd.CommandText = "INSERT INTO StoreFood (storeID,foodName,foodDetails,unitPrice,statusonline,foodPic) VALUES ('" & ddlstore1.SelectedItem.Value & "', '" & txtfoodName.Text.Trim & "', '" & txtfoodDetails.Text & "', '" & txtunitPrice.Text & "' , '" & rdbonline.SelectedValue & "' , '" & UlFileName & "')"
            cmd.Connection = SqlCon

            '*** NEW ROWS ***'
            Dim result As Integer = cmd.ExecuteNonQuery()
            Label12.Text = cmd.CommandText
            SqlCon.Close()
            If result = 1 Then
                loadStoreFood()
            End If
            SqlCon = Nothing

            ResetAll()

        End If
    End Sub

    Protected Sub btncancel_Click(sender As Object, e As ImageClickEventArgs) Handles btncancel1.Click
        ResetAll()
    End Sub

    '*** IMAGEBUTTON EDIT ***'
    Protected Sub gridStoreFood_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles gridStoreFood.RowEditing
        gridStoreFood.EditIndex = e.NewEditIndex
        loadStoreFood()
    End Sub

    Protected Sub gridStoreFood_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles gridStoreFood.RowCancelingEdit
        gridStoreFood.EditIndex = -1
        loadStoreFood()
    End Sub

    Sub ShowPageCommand(sender As Object, e As GridViewPageEventArgs) Handles gridStoreFood.PageIndexChanging
        gridStoreFood.PageIndex = e.NewPageIndex
        loadStoreFood()
    End Sub

    '*** IMAGEBUTTON DELETE ***'
    Protected Sub gridStoreFood_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles gridStoreFood.RowDeleting
        Dim SqlCon As New SqlConnection(con)
        Dim rkey As String = gridStoreFood.DataKeys(e.RowIndex).Values("rkey").ToString()
        Dim cmd As New SqlCommand("DELETE FROM StoreFood WHERE rkey = '" + rkey + "'", SqlCon)
        SqlCon.Open()
        cmd.ExecuteNonQuery()

        gridStoreFood.EditIndex = -1
        SqlCon.Close()
        loadStoreFood()

    End Sub

    Protected Sub gridStoreFood_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gridStoreFood.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim ddlstore1 As DropDownList = CType(e.Row.FindControl("ddlstore1"), DropDownList)
            If Not IsNothing(ddlstore1) Then
                ddlstore1.DataSource = DropdownlistStore()
                ddlstore1.DataTextField = "storeName"
                ddlstore1.DataValueField = "storeID"
                ddlstore1.DataBind()
                'ddlstore1.Items.Insert(0, New ListItem("เลือกร้านอาหาร", "0"))
                ddlstore1.SelectedValue = ddlstore1.Items.IndexOf(ddlstore1.Items.FindByValue(e.Row.DataItem("storeID")))

            End If

            Dim lblfoodName As Label = CType(e.Row.FindControl("lblfoodName"), Label)
            If Not IsNothing(lblfoodName) Then
                lblfoodName.Text = e.Row.DataItem("foodName")
            End If

            Dim lblfoodDetails As Label = CType(e.Row.FindControl("lblfoodDetails"), Label)
            If Not IsNothing(lblfoodDetails) Then
                lblfoodDetails.Text = e.Row.DataItem("foodDetails")
            End If

            Dim lblunitPrice As Label = CType(e.Row.FindControl("lblunitPrice"), Label)
            If Not IsNothing(lblunitPrice) Then
                lblunitPrice.Text = e.Row.DataItem("unitPrice")
            End If

            Dim lblstatusonline As Label = CType(e.Row.FindControl("lblstatusonline"), Label)
            If Not IsNothing(lblstatusonline) Then
                If e.Row.DataItem("statusonline") = "0" Then
                    lblstatusonline.Text = "ปิดร้าน"
                Else
                    lblstatusonline.Text = "เปิดร้าน"
                End If
            End If
        End If
    End Sub

    Protected Sub gridStoreFood_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles gridStoreFood.RowUpdating

        'Dim storeID As TextBox = CType(gridStore.Rows(e.RowIndex).FindControl("txtstoreID"), TextBox)
        Dim rkey As String = gridStoreFood.DataKeys(e.RowIndex).Values("rkey").ToString()
        Dim ddlstore1 As DropDownList = CType(gridStoreFood.Rows(e.RowIndex).FindControl("ddlstore1"), DropDownList)
        Dim foodName As TextBox = CType(gridStoreFood.Rows(e.RowIndex).FindControl("txtfoodName"), TextBox)
        Dim foodDetails As TextBox = CType(gridStoreFood.Rows(e.RowIndex).FindControl("txtfoodDetails"), TextBox)
        Dim unitPrice As TextBox = CType(gridStoreFood.Rows(e.RowIndex).FindControl("txtunitPrice"), TextBox)
        Dim statusonline As RadioButtonList = CType(gridStoreFood.Rows(e.RowIndex).FindControl("rdbonline"), RadioButtonList)
        Dim fiUpload As FileUpload = CType(gridStoreFood.Rows(e.RowIndex).FindControl("fiUpload"), FileUpload)

        Dim UlFileName As String = "Image_Food/" & fiUpload.FileName
        'Dim strUpdateFile = String.Empty
        If fiUpload.HasFile Then
            UlFileName += fiUpload.FileName
            fiUpload.SaveAs(Server.MapPath(UlFileName))
            'strUpdateFile = "storePic='" & UlFileName & "' "
        Else
            Dim img As System.Web.UI.WebControls.Image = CType(gridStoreFood.Rows(e.RowIndex).FindControl("imageUser"), System.Web.UI.WebControls.Image)
            UlFileName = img.ImageUrl

        End If

        Dim SqlCon As New SqlConnection(con)
        Dim cmd As New SqlCommand("UPDATE StoreFood SET storeID='" & ddlstore1.SelectedItem.Value & "', foodName='" & foodName.Text & "', foodDetails='" & foodDetails.Text & "', unitPrice='" & unitPrice.Text & "', statusonline='" & statusonline.SelectedValue & "', foodPic='" & UlFileName & "' WHERE rkey='" & gridStoreFood.DataKeys.Item(e.RowIndex).Value & "'", SqlCon)
        SqlCon.Open()
        cmd.ExecuteNonQuery()
        SqlCon.Close()


        gridStoreFood.EditIndex = -1
        loadStoreFood()


    End Sub

    Sub checknull()

    End Sub


    '*** BUTTON CANCEL ***'
    Protected Sub ResetAll()
        ddlstore1.SelectedIndex = ddlstore1.Items.IndexOf(ddlstore1.Items.FindByValue("0"))
        txtfoodName.Text = ""
        txtfoodDetails.Text = ""
        txtunitPrice.Text = ""
        rdbonline.SelectedIndex = rdbonline.Items.IndexOf(rdbonline.Items.FindByValue("1"))
    End Sub

End Class

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-29 15:26:33 By : heaunn
 

 

No. 3



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์


ฝั่ง aspx
Code
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site2.Master" CodeBehind="Food.aspx.vb" Inherits="Order.Food1" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <h3 class="page-title">การจัดการรายการอาหาร</h3> <form id="form1" runat="server"> <div> <%--FORM--%> <br /> <asp:Table runat="server" HorizontalAlign="Center" CellSpacing="5"> <asp:TableRow> <asp:TableCell> <asp:Label ID="Label1" runat="server" Text="ร้านค้า:"></asp:Label> </asp:TableCell> <asp:TableCell> <asp:DropDownList ID="ddlstore1" runat="server" Width="200px" Style="font-family: Tahoma; font-size: 14px"></asp:DropDownList> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Label ID="Label2" runat="server" Text="ชื่ออาหาร:"></asp:Label> </asp:TableCell> <asp:TableCell> <asp:TextBox ID="txtfoodName" runat="server" Width="200px" Style="font-family: Tahoma; font-size: 14px"></asp:TextBox> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Label ID="Label3" runat="server" Text="รายละเอียด:"></asp:Label> </asp:TableCell> <asp:TableCell> <asp:TextBox runat="server" ID="txtfoodDetails" TextMode="Multiline" Columns="40" Rows="4" Style="font-family: Tahoma; font-size: 14px"></asp:TextBox> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Label ID="Label4" runat="server" Text="ราคา:"></asp:Label> </asp:TableCell> <asp:TableCell> <asp:TextBox ID="txtunitPrice" runat="server" Width="45px" MaxLength="4"></asp:TextBox>&nbsp;&nbsp;<asp:Label ID="Label5" runat="server" Text="บาท"></asp:Label> <%--<asp:RegularExpressionValidator id="myRegValid" runat="server" ErrorMessage="กรุณาใส่ตัวเลข" ControlToValidate="txtunitPrice" ValidationExpression="(^([0-9]*|\d*\d{1}?\d*)$)" ForeColor="Red" Font-Size="Smaller"></asp:RegularExpressionValidator><br />--%> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Label ID="Label6" runat="server" Text="สถานะ:"></asp:Label> </asp:TableCell> <asp:TableCell> <asp:RadioButtonList ID="rdbonline" runat="server" RepeatDirection="horizontal"> <asp:ListItem Text="เปิด" Value="1" Selected ="True"></asp:ListItem> <asp:ListItem Text="ปิด" Value="0"></asp:ListItem> </asp:RadioButtonList> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Label ID="Label7" runat="server" Text="รูปภาพ:"></asp:Label> </asp:TableCell> <asp:TableCell> <asp:FileUpload ID="fiUpload" runat="server" /> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell ColumnSpan="2" HorizontalAlign="Center"> <asp:ImageButton ID="buttonSave" CommandName="Save" runat="server" OnClick="buttonSave_click" ImageUrl="~/Images/Save.png" />&nbsp;&nbsp;<asp:ImageButton ID="btncancel1" runat="server" CommandName="Cancel" OnClick="btncancel_click" ImageUrl="~/Images/cancel.png" /> </asp:TableCell> </asp:TableRow> </asp:Table> <br /> <%--GRIDVIEW--%> <asp:Table runat="server" Height="100%" Width="100%" HorizontalAlign="Center"> <asp:TableRow> <asp:TableCell HorizontalAlign="Center"> <asp:GridView ID="gridStoreFood" DataKeyNames="rkey" runat="server" Width="1050px" AutoGenerateColumns="False" AllowPaging="True" PageSize="5" HeaderStyle-Font-Bold="true" Style="text-align: center" CellPadding="4" ForeColor="#333333" GridLines="None"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:TemplateField HeaderText="รหัส" ItemStyle-Width="50px"> <ItemTemplate> <asp:Label ID="lblrkey" Text='<%#Eval("rkey") %>' runat="server" /> </ItemTemplate> <ItemStyle Width="40px"></ItemStyle> </asp:TemplateField> <asp:TemplateField HeaderText="ร้านอาหาร" ItemStyle-Width="150px"> <ItemTemplate> <asp:Label ID="lblstoreID" Text='<%#Eval("storeID") %>' runat="server" /> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlstore1" runat="server" Width="120px" Style="font-family: Tahoma; font-size: 14px"></asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ชื่ออาหาร" ItemStyle-Width="150px"> <ItemTemplate> <asp:Label ID="lblfoodName" Text='<%#Eval("foodName") %>' runat="server" /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtfoodName" Text='<%#Eval("foodName")%>' runat="server" Width="120px" Style="font-family: Tahoma; font-size: 14px"></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="รายละเอียด" ItemStyle-Width="250px"> <ItemTemplate> <asp:Label ID="lblfoodDetails" Text='<%#Eval("foodDetails") %>' runat="server" Style="text-align: left" /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtfoodDetails" Text='<%#Eval("foodDetails") %>' runat="server" TextMode="Multiline" Columns="30" Rows="4" Style="font-family: Tahoma; font-size: 14px"></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ราคา" ItemStyle-Width="50px"> <ItemTemplate> <asp:Label ID="lblunitPrice" Text='<%#Eval("unitPrice") %>' runat="server" Style="text-align: right" /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtunitPrice" Text='<%#Eval("unitPrice")%>' runat="server" Width="40px" Style="font-family: Tahoma; font-size: 14px"></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="สถานะการขาย"> <ItemTemplate> <asp:Label ID="lblstatusonline" Text='<%#Eval("statusonline") %>' runat="server" /> </ItemTemplate> <EditItemTemplate> <asp:RadioButtonList ID="rdbonline" runat="server" Style="text-align: left"> <asp:ListItem Text="เปิดร้าน" Value="1" Selected="True"></asp:ListItem> <asp:ListItem Text="ปิดร้าน" Value="0"></asp:ListItem> </asp:RadioButtonList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="รูปภาพ" ItemStyle-Width="150px"> <ItemTemplate> <asp:Image ID="imageStore" runat="server" Width="120px" Height="120px" ImageUrl='<%#Eval("foodPic") %>'></asp:Image> </ItemTemplate> <EditItemTemplate> <asp:Image ID="imageUser" runat="server" Width="120px" Height="120px" ImageUrl='<%#Eval("foodPic") %>'></asp:Image> <br /> <asp:FileUpload ID="fiUpload" runat="server" /> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:ImageButton ID="imageEdit" runat="server" CommandName="Edit" Width="20px" Height="20px" ImageUrl="~/Images/edit.png" /> <asp:ImageButton ID="imageDel" runat="server" CommandName="Delete" Width="20px" Height="20px" ImageUrl="~/Images/0049-Trash-icon.png" OnClientClick="return confirm('คุณต้องการลบใช่หรือไม่?')" /> </ItemTemplate> <EditItemTemplate> <asp:ImageButton ID="imageUpdate" runat="server" CommandName="Update" Width="20px" Height="20px" ImageUrl="~/Images/Check.png" /> <asp:ImageButton ID="imageCancel" runat="server" CommandName="Cancel" Width="20px" Height="20px" ImageUrl="~/Images/Delete.png" /> </EditItemTemplate> </asp:TemplateField> </Columns> <EditRowStyle BackColor="#FFC643" /> <FooterStyle BackColor="#FF9933" Font-Bold="True" ForeColor="#363422" /> <HeaderStyle Font-Bold="True" BackColor="#FF9933" ForeColor="#363422"></HeaderStyle> <PagerStyle BackColor="#FF9933" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#FFFFCC" /> <SelectedRowStyle BackColor="#FF9933" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#fff" /> <SortedAscendingHeaderStyle BackColor="#fff" /> <SortedDescendingCellStyle BackColor="#fff" /> <SortedDescendingHeaderStyle BackColor="#fff" /> </asp:GridView> </asp:TableCell> </asp:TableRow> </asp:Table> <asp:Label ID="Label12" runat="server" Text="Label"></asp:Label> </div> </form> </asp:Content>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-29 15:30:32 By : heaunn
 


 

No. 4



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์


ยังไม่ได้วิธีแก้เลยค่ะ


ประวัติการแก้ไข
2015-10-30 09:05:51
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 09:02:40 By : heaunn
 


 

No. 5



โพสกระทู้ ( 4,434 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ตรงไหนที่บอกว่า RadioButtonList เอาค่าจากตารางมาเซ็ตค่าเรอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 10:10:36 By : lamaka.tor
 


 

No. 6



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์


ข้อมูลที่อยู่ในตารางพอกด Edit แล้วมันจะไม่เซ็ทค่าตรงกับตารางกด Edit ค่ะ (มันจะเซ็ทค่า default แทนค่ะ)
เราก็ไม่รู้ว่าต้องเขียนโค้ดยังไงให้มันเซ็ทค่าตามที่แสดงข้อมูลในตาราง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 12:46:11 By : heaunn
 


 

No. 7



โพสกระทู้ ( 4,434 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

<asp:RadioButtonList ID="rdbonline" runat="server" Style="text-align: left">
<asp:ListItem Text="เปิดร้าน" Value="1" Selected="True"></asp:ListItem>
<asp:ListItem Text="ปิดร้าน" Value="0"></asp:ListItem>
</asp:RadioButtonList>

มันจะเซ็ทค่า default แทนค่ะ

ตรงไหนที่บอกว่า RadioButtonList เอาค่าจากตารางมาเซ็ตค่าเรอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 13:16:59 By : lamaka.tor
 


 

No. 8



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์


ตรงนี้เราเซ็ทให้มัน default ที่เปิดร้าน แต่ตอนที่เพิ่มข้อมูลเข้ามา จะเพิ่มจากฟอร์มเข้ามาให้ตาราง
พอเข้ามาแล้วในตารางจะมีให้กดแก้ไขได้ ซึ่งตรงนี้แหละค่ะที่เราไม่เข้าใจว่าควรจะเขียนโค้ดยังไงให้มันเซ็ตค่าตามข้อมูลที่เพิ่มมาอ่ะค่ะ เพราะเราเขียนโค้ดไปแบบนั้นแล้วมันเซ็ทค่า default ตลอดเลย เราควรแก้โค้ดตรงไหนหรือเพิ่มตรงไหนคะ เราไม่ค่อยเข้าใจเท่าไร


ประวัติการแก้ไข
2015-10-30 13:41:48
2015-10-30 13:42:40
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 13:40:50 By : heaunn
 


 

No. 9



โพสกระทู้ ( 4,434 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

อันดับแรก

พอกด Edit ต้องใช้ select .... where ???

ถ้า select เฉยๆมันจะเลือกค่าแรกมาอยู่แล้วครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 13:51:43 By : lamaka.tor
 


 

No. 10



โพสกระทู้ ( 123 )
บทความ ( 0 )



สถานะออฟไลน์


เราควรเขียนโค้ดยังไงค่ะ เราพึ่งเคยเขียนโค้ดที่ต้องใช้ร่วมกับ Database ครั้งแรกเลยยังงงๆ อยู่ค่ะ


ประวัติการแก้ไข
2015-10-30 14:02:49
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 14:02:16 By : heaunn
 


 

No. 11



โพสกระทู้ ( 4,434 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 10 เขียนโดย : heaunn เมื่อวันที่ 2015-10-30 14:02:16
รายละเอียดของการตอบ ::
พอกด Edit ต้องใช้ select .... where ???
RadioButtonList ใช้ if ในการจัดการ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 15:24:11 By : lamaka.tor
 


 

No. 12



โพสกระทู้ ( 4,434 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

https://www.thaicreate.com/asp.net/c-sharp-asp.net-radiobuttonlist-databind.html
https://www.thaicreate.com/asp.net/asp.net-web-control-radiobuttonlist.html


ประวัติการแก้ไข
2015-10-30 15:28:13
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-10-30 15:27:46 By : lamaka.tor
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ข้อมูลเมื่อกด Edit ของ Dropdownlist และ RadiobuttonList in Gridview ไม่แสดงค่าปัจจุบัน (ยังไม่ได้คำตอบเลยค่ะ)
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่