开发者

Loop through controls and change LINQ columns

开发者 https://www.devze.com 2023-01-04 22:13 出处:网络
I have the following code: Dim i As Integer For i = 1 To 20 Dim captionTextBox As TextBox = DirectCast(Me.FindControl(\"news_Image\" + i.ToString() + \"CaptionTextBox\"), TextBox)

I have the following code:

 Dim i As Integer
    For i = 1 To 20
        Dim captionTextBox As TextBox = DirectCast(Me.FindControl("news_Image" + i.ToString() + "CaptionTextBox"), TextBox)
        Dim deleteCheckBox As CheckBox = DirectCast(Me.FindControl("Image" + i.ToString() + "DeleteCheckBox"), CheckBox)
        If Not deleteCheckBox.Checked = False Then
            If Not captionTextBox.Text = "" Then
                'Insert the value of the textbox into the column like news_Image1Caption, news_image2Caption nased on the value of i
            End If
        End If
    Next

Where the comment is in the code above, I need to insert the value of the textbox (text) into Linq columns. For example: articleToUpdate.news_Image1Caption, news_Image2Caption, b开发者_开发技巧ut I need to change the number after news_ to the value of i in the for loop. How can I do this?

Thanks

Luke


Did you try to set the ID column to Auto-Generated Value = true ?

INSERT INTO [dbo].[s_Tbl]([ID], [news_Image1Caption], [news_image2Caption]) VALUES (...)
0

精彩评论

暂无评论...
验证码 换一张
取 消