 |
|
get ค่า Id ได้แต่ Section ใน FindControl Gridview ไม่ได้ครับลองหลายวิธีแล้วครับ |
|
 |
|
|
 |
 |
|
คือว่าผมต้องการ Update ข้อมูลโดยทำตามตัวอย่างนี้ครับ
https://www.thaicreate.com/asp.net/asp.net-gridview-control-dropdownlist.html
โดยทำการ Update ได้แล้วทั้ง Textbox, Dropdownlistbox, datetimepicker, other แต่ติดตรง Export excel ดึง id มาได้แต่ Section ไม่ได้ครับเนื่องจาก id กับ Section เป็น key รวม แต่การ update ดึงได้เพราะว่าใช้แบบนี้ครับ
Code (VB.NET)
Dim txtReqSubj As TextBox = CType(myGridView.Rows(e.RowIndex).FindControl("txtEditReqSubj"), TextBox)
แต่ get Export excel get ได้เฉพาะ id ครับ section get มาไม่ได้ที่ลองไปแล้วมี
Protected Sub ExportFile(ByVal sender As Object, ByVal e As EventArgs)
HTML
<asp:TemplateField HeaderText="Exported">
<ItemTemplate>
<asp:LinkButton ID="lnkExpReqSheet" Text ="Exported" runat ="server" OnClick ="ExportFile"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
ASP.NET
Dim index As Integer = gvRow.RowIndex
Dim reqID As String = myGridView.DataKeys.Item(index).Value() ' ได้
Dim SecName As String = myGridView.Rows(index).Cells(11).Text.ToString() ' ไม่ได้
Dim test As String = myGridView.DataKeys.Item(index).Value()
'Dim reqId1 As DropDownList = CType(myGridView.Rows(index).FindControl("txtEditRequestID"), DropDownList) ' ไม่ได้
'Dim SecName1 As DropDownList = CType(myGridView.Rows(index).FindControl("txtEditSection"), DropDownList) ' ไม่ได้
End Sub
ช่วยหน่อยครับโผม
Tag : .NET, Ms SQL Server 2012, HTML/CSS, Web (ASP.NET), VS 2008 (.NET 3.x), Windows
|
|
 |
 |
 |
 |
Date :
2014-10-15 12:01:49 |
By :
TotEcom |
View :
907 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
EditItemTemplate อันนี้ Mode Edit เปิดแล้วใช่หรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2014-10-15 13:53:53 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันได้ได้ครับเพราะว่า ByVal sender As Object, ByVal e As EventArgs พอผมจะแก้มันก็ Error ครับ
Code (VB.NET)
Protected Sub ExportFile(ByVal sender As Object, ByVal e As EventArgs)
End Sub
แต่ถ้าเป็นแบบนี้
Code (VB.NET)
Sub modUpdateCommand(ByVal s As Object, ByVal e As GridViewUpdateEventArgs)
'*** Section ***'
Dim txtSection As TextBox = CType(myGridView.Rows(e.RowIndex).FindControl("txtEditSection"), TextBox)
End Sub
ถึงจะใส่ได้ครับ


|
ประวัติการแก้ไข 2014-10-15 14:00:30 2014-10-15 14:03:13 2014-10-15 14:20:46 2014-10-15 14:24:46 2014-10-15 14:28:02
 |
 |
 |
 |
Date :
2014-10-15 13:59:30 |
By :
TotEcom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้เลยครับพี่ ๆ ช่วยหน่อยครับ
|
ประวัติการแก้ไข 2014-10-15 15:04:53
 |
 |
 |
 |
Date :
2014-10-15 14:40:26 |
By :
TotEcom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|