|
|
|
ชอความช่วยเหลือครับเกี่ยวกับ Girdview ต้องการคลิกแล้วโชว์ที่ Label1 |
|
|
|
|
|
|
|
ขอรบกวนถามหน่อยครับ
- ทำยังไงครับให้ คอลัม List_ID สามารถกดได้(คล้ายๆลิ้ง Button)
- พอ คลิก แล้วจะโชว์ชื่อที่ Label 1 แล้ว
- แล้วอยากถามว่าผมจะเก็บค่าที่คลิกเป็น String เพื่อส่งข้ามไปอีกฟอร์ม จะทำยังไงครับ
เช่นถ้าผมคลิกที่ T00002 แล้วแสดงที่ Label1 "T00002"
Code (ASP)
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Send_Page_To_Page._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None" DataKeyNames="ID"
DataSourceID="SqlDataSource1" style="text-align: center" Width="606px">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="List_ID" HeaderText="List_ID"
SortExpression="List_ID" />
<asp:BoundField DataField="Data1" HeaderText="Data1" SortExpression="Data1" />
<asp:BoundField DataField="Data2" HeaderText="Data2" SortExpression="Data2" />
<asp:BoundField DataField="Data3" HeaderText="Data3" SortExpression="Data3" />
</Columns>
<EditRowStyle BackColor="#2461bf" />
<FooterStyle BackColor="#507cd1" Font-Bold="true" ForeColor="White" />
<HeaderStyle BackColor="#507cd1" Font-Bold="true" ForeColor="White" />
<PagerStyle BackColor="#507cd1" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#efe3fb" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="true" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
DeleteCommand="DELETE FROM [Data] WHERE [ID] = @original_ID AND (([List_ID] = @original_List_ID) OR ([List_ID] IS NULL AND @original_List_ID IS NULL)) AND (([Data1] = @original_Data1) OR ([Data1] IS NULL AND @original_Data1 IS NULL)) AND (([Data2] = @original_Data2) OR ([Data2] IS NULL AND @original_Data2 IS NULL)) AND (([Data3] = @original_Data3) OR ([Data3] IS NULL AND @original_Data3 IS NULL))"
InsertCommand="INSERT INTO [Data] ([List_ID], [Data1], [Data2], [Data3]) VALUES (@List_ID, @Data1, @Data2, @Data3)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Data]"
UpdateCommand="UPDATE [Data] SET [List_ID] = @List_ID, [Data1] = @Data1, [Data2] = @Data2, [Data3] = @Data3 WHERE [ID] = @original_ID AND (([List_ID] = @original_List_ID) OR ([List_ID] IS NULL AND @original_List_ID IS NULL)) AND (([Data1] = @original_Data1) OR ([Data1] IS NULL AND @original_Data1 IS NULL)) AND (([Data2] = @original_Data2) OR ([Data2] IS NULL AND @original_Data2 IS NULL)) AND (([Data3] = @original_Data3) OR ([Data3] IS NULL AND @original_Data3 IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_List_ID" Type="String" />
<asp:Parameter Name="original_Data1" Type="String" />
<asp:Parameter Name="original_Data2" Type="String" />
<asp:Parameter Name="original_Data3" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="List_ID" Type="String" />
<asp:Parameter Name="Data1" Type="String" />
<asp:Parameter Name="Data2" Type="String" />
<asp:Parameter Name="Data3" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="List_ID" Type="String" />
<asp:Parameter Name="Data1" Type="String" />
<asp:Parameter Name="Data2" Type="String" />
<asp:Parameter Name="Data3" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_List_ID" Type="String" />
<asp:Parameter Name="original_Data1" Type="String" />
<asp:Parameter Name="original_Data2" Type="String" />
<asp:Parameter Name="original_Data3" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
แสดงผล :
<asp:Label ID="Label1" runat="server" style="font-weight: 700" Text="Label1"></asp:Label>
</form>
</body>
</html>
Tag : ASP, VB.NET
|
|
|
|
|
|
Date :
2015-06-13 15:43:41 |
By :
treesak113 |
View :
934 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เงียบจัง สงสัยวันหยุดทุกคนก้อหยุด
|
|
|
|
|
Date :
2015-06-14 13:02:05 |
By :
treesak113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนเป็น LinkButton ครับ แนะนำให้ไปใช้พวก Template Field แทนน่ะครับ
ASP.NET GridView Control
|
|
|
|
|
Date :
2015-06-15 10:42:29 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|