Vad är det för fel på denna kod. Jag hittar inte panelen som ligger i datagriden. Här är ett exempel på hur man hittar kontroller i en DataGrid vid DataBound. Detta gör du i ItemCreated eller ItemDataBound beroende på om visningen av Panelen skall vara betingat av förekomsten av visst data eller ej. I FooterTemplate har jag en LinkButton som jag har satt CommandName="visa". Har också satt i DataGriden OnItemCommand="visa" I FooterTemplate har jag en LinkButton som jag har satt CommandName="visa". Har också satt i DataGriden OnItemCommand="visa" Istället för att du skall experimentera med detta visar jag kod som jag själv använder för att lägga till en nyhet: Ok, nu funkar det. Tog ett tag innan jag förstod Vad ItemDataBound gjorde:Hur hitta kontroll i datagrid?
Hur ska jag göra för att hitta kontroller i datagriden?
<code>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
bindDataGrid()
End If
End Sub
Private Sub bindDataGrid()
Dim ds As DataSet
Dim db As New clsDatabas
Dim sql As String
sql = "SELECT * FROM Nyheter"
ds = db.skapaDataset(sql)
dgNyheter.DataSource = ds.Tables("Nyheter")
dgNyheter.DataBind()
Dim kontrollItem As DataGridItem
Dim kontroll As Panel
For Each kontrollItem In dgNyheter.Items
If TypeOf kontrollItem Is Panel Then
kontroll = CType(kontrollItem.FindControl("pnlNy"), Panel)
kontroll.Visible = False
End If
Next
</code>Sv: Hur hitta kontroll i datagrid?
<code>
Sub dgrRooms_DataBind(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If item = ListItemType.Item Or item = ListItemType.AlternatingItem Then
Dim tmpRooms As Label = CType(e.Item.FindControl("rooms"), Label)
If tmpRooms.Text = 0 Then
tmpRooms.Visible = False
End If
End If
End Sub
</code>
/pD
www.pdc.se
www.pdc.se/blog
www.patrik-dahlen.nuSv: Hur hitta kontroll i datagrid?
<code>
Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Dim item As ListItemType = e.Item.ItemType
Dim pnl As Panel
Select Case item
Case ListItemType.AlternatingItem, ListItemType.Item
pnl = CType(e.Item.FindControl("pnlNy"), Panel)
pnl.Visible = False
Case ListItemType.Header
'Inget
Case ListItemType.Footer
'Inget
End Select
End Sub
</code>
..Eller
<code>
Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Dim item As ListItemType = e.Item.ItemType
Dim pnl As Panel
Select Case item
Case ListItemType.AlternatingItem, ListItemType.Item
pnl = CType(e.Item.FindControl("pnlNy"), Panel)
If (e.Item.DataItem("MittDataFält") = <nåt värde>) Then
pnl.Visible = False
End If
Case ListItemType.Header
'Inget
Case ListItemType.Footer
'Inget
End Select
End Sub
</code>Sv: Hur hitta kontroll i datagrid?
Denna ropar på funktion som gör panelen synlig i foten på DataGriden. Det är här jag ska kunna lägga till en ny nyhet:
Sub visa(ByVal obj As Object, ByVal e As DataGridCommandEventArgs)
If CType(e.Item.FindControl("pnlNy"), Panel).Visible = False Then
CType(e.Item.FindControl("pnlNy"), Panel).Visible = True
CType(e.Item.FindControl("lnkLaggtill"), LinkButton).Visible = False
dgNyheter.Attributes("panel") = "true"
End If
End Sub
Hur ska jag kunna ropa på ItemDataBound från LinkButton då CommandName är upptaget?
Då får gärna visa hur jag ska kunna komma åt funktionerna du visat?Sv: Hur hitta kontroll i datagrid?
Denna ropar på funktion som gör panelen synlig i foten på DataGriden. Det är här jag ska kunna lägga till en ny nyhet:
Sub visa(ByVal obj As Object, ByVal e As DataGridCommandEventArgs)
If CType(e.Item.FindControl("pnlNy"), Panel).Visible = False Then
CType(e.Item.FindControl("pnlNy"), Panel).Visible = True
CType(e.Item.FindControl("lnkLaggtill"), LinkButton).Visible = False
dgNyheter.Attributes("panel") = "true"
End If
End Sub
Jag vill kunna styra panelen i funktionen bindDatagrid() och där hittar jag inte kontrollen.
Hur ska jag kunna ropa på ItemDataBound från LinkButton då CommandName är upptaget?
Då får gärna visa hur jag ska kunna komma åt funktionerna du visat?
Är nybörjare med datagrid:-(Sv: Hur hitta kontroll i datagrid?
.aspx sidan först:
<code>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="admnews.aspx.vb" Inherits="BrogatanNew.admnews" %>
<%@ Import Namespace="BrogatanNew.GlobalComponents" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>admnews</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<LINK href="../Styles.css" type="text/css" rel="stylesheet">
</HEAD>
<body>
<FORM id="Form1" method="post" runat="server">
<table align="center">
<tr Runat="server">
<td align="center" Runat="server">
<table width="600" cellspacing="0" cellpadding="0" style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid">
<tr Class="AdminTopBackGroundColor">
<td Runat="server" height="50" style="BORDER-BOTTOM: black 1px inset" align="center"
colspan="3">
<asp:Label id="Label2" runat="server" style="LETTER-SPACING:1px" Font-Names="Geneva,Verdana,Arial,Sans-Bold"
ForeColor="WhiteSmoke" Font-Size="10px" Font-Bold="true"></asp:Label>
</td>
</tr>
<tr Runat="server" id="trMessage" bgcolor="whitesmoke" visible="false">
<td Runat="server" height="50" style="BORDER-BOTTOM: black 1px inset" align="center"
colspan="3">
<asp:Label Id="lblmessage" RunAt="server" />
</td>
</tr>
<tr Class="NavRowBGColor">
<td height="10" colspan="3" Class="NavMenuCell">
TILL
ADMINMENYN
<asp:LinkButton Id="lbtnShow" RunAt="server" Style="FONT-SIZE: 10px" Text="<img src='../images/pil.gif' alt='' border='0'>LÄGG TILL NYHET"
CausesValidation="false" />
<asp:LinkButton Id="lbtnHide" RunAt="server" Style="FONT-SIZE: 10px" Text="<img src='../images/pil.gif' alt='' border='0'>DÖLJ FORMULÄR"
CausesValidation="false" Visible="false" />
LOGGA UT
</td>
</tr>
<tr Id="trNew" runat="server" Visible="false">
<td RunAt="server" valign="top">
<table Runat="server" style="PADDING-RIGHT: 10px;BORDER-TOP: black 1px solid;PADDING-LEFT: 10px;PADDING-BOTTOM: 10px;PADDING-TOP: 10px"
bgcolor="whitesmoke" Width="100%">
<tr Runat="server">
<td Runat="Server" style="PADDING-LEFT: 10px;PADDING-TOP: 10px">
<font color="black" style="FONT-SIZE: 10px">HÄR LÄGGER DU TILL NYHETER ATT VISA PÅ
<BR>
<%= strCo.ToUpper %>
:S STARTSIDA PÅ INTERNET. </font>
</td>
</tr>
<tr Runat="server">
<td Runat="Server" style="PADDING-LEFT: 10px;PADDING-TOP: 10px">
<font color="black">RUBRIK:</font><br>
</td>
<td Runat="Server" style="PADDING-LEFT: 10px;PADDING-TOP: 10px">
<font color="black">NYHET:</font><br>
</td>
<td Runat="Server" style="PADDING-LEFT: 10px;PADDING-TOP: 10px">
<br>
</td>
</tr>
<tr Runat="server">
<td Runat="Server" style="PADDING-RIGHT: 5px;PADDING-LEFT: 10px;PADDING-TOP: 5px" valign="top">
<asp:TextBox Id="txtRubrik" CssClass="txtDetalj" Columns="35" MaxLength="100" RunAt="server"
ReadOnly="false" AutoPostBack="false" TabIndex="1" />
<br>
<asp:RequiredFieldValidator id="rvalRubrik" RunAt="server" ControlToValidate="txtRubrik" EnableClientScript="False"
Style="COLOR: red" Text="* Måste innehålla text!!" Display="Dynamic" />
<br>
<asp:Button Id="btnSend" RunAt="server" CssClass="drpDetalj" Text="REGISTRERA NYHET" CausesValidation="true"
TabIndex="3" />
</td>
<td Runat="Server" style="PADDING-RIGHT: 5px;PADDING-LEFT: 10px;PADDING-TOP: 5px" valign="top">
<asp:TextBox Id="txtNews" CssClass="txtDetalj" RunAt="server" Rows="10" Columns="50" ReadOnly="false"
TextMode="MultiLine" AutoPostBack="false" TabIndex="2" />
<br>
<asp:RequiredFieldValidator id="rvalNews" RunAt="server" ControlToValidate="txtNews" EnableClientScript="False"
Style="COLOR: red" Text="* Måste innehålla text!!" Display="Dynamic" />
</td>
<td Runat="Server" style="PADDING-LEFT: 10px;PADDING-TOP: 5px">
<br>
</td>
</tr>
<tr Runat="server">
<td Runat="Server" style="PADDING-LEFT: 10px">
<br>
</td>
</tr>
</table>
</td>
</tr>
<tr Runat="server" ID="trList">
<td Runat="server" style="FONT-SIZE: 10px">
<asp:DataGrid Id="myGrid" RunAt="server" CellPadding="5" CellSpacing="0" GridLines="None" DataKeyField="newsid"
HeaderStyle-BackColor="PaleGoldenRod" HeaderStyle-ForeColor="#000000" ItemStyle-BackColor="#F5F5F5"
ItemStyle-ForeColor="#000000" ItemStyle-VerticalAlign="Top" AlternatingItemStyle-BackColor="#DCDCDC"
AlternatingItemStyle-ForeColor="#000000" AlternatingItemStyle-Width="500" AlternatingItemStyle-VerticalAlign="Top"
SelectedItemStyle-BackColor="#00FF00" SelectedItemStyle-ForeColor="#000000" EditItemStyle-ForeColor="#000000"
FooterStyle-BackColor="PaleGoldenRod" FooterStyle-ForeColor="#000000" PagerStyle-Visible="true"
AutoGenerateColumns="false" ShowFooter="false" Width="100%" AllowPaging="true" PageSize="10"
PagerStyle-NextPageText=">" PagerStyle-Position="Bottom" PagerStyle-PrevPageText="<" PagerStyle-BorderColor="Black"
PagerStyle-BorderStyle="Solid" PagerStyle-BorderWidth="1px" PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Left" edititemstyle-backcolor="LightSteelBlue" PagerStyle-BackColor="DarkRed">
<columns>
<asp:TemplateColumn HeaderText="RUBRIK" HeaderStyle-CssClass="10px" ItemStyle-Width="100" ItemStyle-BorderColor="Black"
ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1px" HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid"
HeaderStyle-BorderWidth="1px">
<ItemTemplate>
<%# Container.DataItem( "headline" ) %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtHeadline" Runat=server Text='<%# Container.DataItem( "headline" ) %>' CssClass="txtDetalj">
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="NYHET" HeaderStyle-CssClass="10px" ItemStyle-Width="250" ItemStyle-BorderColor="Black"
ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1px" HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid"
HeaderStyle-BorderWidth="1px">
<ItemTemplate>
<%# truncateDescription(Container.DataItem( "body" )) %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=txtBody Runat=server TextMode=MultiLine text='<%# MakeWebFormString(Container.DataItem( "body" )) %>' CssClass="txtDetalj" Columns="50" Rows="10">
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="DATUM" HeaderStyle-CssClass="10px" ItemStyle-BorderColor="Black" ItemStyle-BorderStyle="Solid"
ItemStyle-BorderWidth="1px" HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px">
<ItemTemplate>
<%# DataBinder.Eval( Container.DataItem, "created", "{0:d}" ) %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn HeaderText="REDIGERA" HeaderStyle-CssClass="10px" ItemStyle-CssClass="btnOlive"
ButtonType="PushButton" CancelText="A" EditText="R" UpdateText="U" ItemStyle-BorderColor="Black" ItemStyle-BorderStyle="Solid"
ItemStyle-BorderWidth="1px" HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"></asp:EditCommandColumn>
<asp:ButtonColumn Text="RADERA" HeaderText="RADERA" CommandName="Delete" HeaderStyle-CssClass="10px"
ItemStyle-BorderColor="Black" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1px" HeaderStyle-BorderColor="Black"
HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px" ItemStyle-VerticalAlign="Middle"
ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"></asp:ButtonColumn>
</columns>
</asp:DataGrid>
</td>
</tr>
</table>
</td>
</tr>
</table>
</FORM>
</body>
</HTML>
</code>
..och sedan Code Behind. Jag har använt VS.Net till detta. Fråga gärna om det är nåt du undrar. Detta sättet använder jag ofta för att lägga till poster i en DB från en adminsida. Det finns ingen anlednig varför du skall ha inmatningen i Footern.
<code>
Imports System.Data
Imports System.Data.SqlClient
Imports BrogatanNew.GlobalComponents
Public Class admnews
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Table2 As System.Web.UI.HtmlControls.HtmlTable
Protected WithEvents btnSend As System.Web.UI.WebControls.Button
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents lblmessage As System.Web.UI.WebControls.Label
Protected WithEvents myGrid As System.Web.UI.WebControls.DataGrid
Protected WithEvents trMessage As System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents trNew As System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents lbtnShow As System.Web.UI.WebControls.LinkButton
Protected WithEvents lbtnHide As System.Web.UI.WebControls.LinkButton
Protected WithEvents txtRubrik As System.Web.UI.WebControls.TextBox
Protected WithEvents txtNews As System.Web.UI.WebControls.TextBox
Protected strConn As String = ConfigurationSettings.AppSettings("conString")
Protected strTitle As String = String.Concat(ConfigurationSettings.AppSettings("CompanyName"), " ::: Nyheter")
Protected strCo As String = ConfigurationSettings.AppSettings("CompanyName")
Protected WithEvents rvalRubrik As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents rvalNews As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents trList As System.Web.UI.HtmlControls.HtmlTableRow
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
#Region "Private Sub Page_Load"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.btnSend.CausesValidation = True
If Not IsPostBack Then
Me.Label2.Text = String.Concat("ADMINISTRERA NYHETER ::: ", Me.strCo.ToUpper, " ADMIN")
Me.GetData()
End If
End Sub
#End Region
#Region "Private Sub GetData()"
Private Sub GetData()
Dim con As New SqlConnection(strConn)
Dim dst As DataSet
Dim adp As SqlDataAdapter
dst = New DataSet
adp = New SqlDataAdapter("GetAllNews", con)
adp.SelectCommand.CommandType = CommandType.StoredProcedure
adp.Fill(dst, "News")
con.Close()
myGrid.DataSource = dst.Tables("News")
CheckPaging(myGrid)
End Sub
#End Region
#Region "Private Sub myGrid_ItemCreated"
Private Sub myGrid_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles myGrid.ItemCreated
Dim item As ListItemType = e.Item.ItemType
myGrid.PagerStyle.HorizontalAlign = HorizontalAlign.Right
Select Case item
Case ListItemType.Pager
GlobalComponents.DoPaging(myGrid, e)
End Select
End Sub
#End Region
#Region "Private Sub myGrid_ItemDataBound"
Private Sub myGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles myGrid.ItemDataBound
Dim item As ListItemType = e.Item.ItemType
Dim button1 As LinkButton
Dim button3 As Button
Select Case item
Case ListItemType.Item, ListItemType.AlternatingItem
button1 = CType(e.Item.Cells(4).Controls(0), LinkButton)
button1.Attributes.Add("onclick", "return confirm('Är du säker på att du vill radera denna post?');")
Case ListItemType.EditItem
button3 = CType(e.Item.Cells(3).Controls(0), Button)
button3.CausesValidation = False
btnSend.CausesValidation = False
button1 = CType(e.Item.Cells(4).Controls(0), LinkButton)
button1.Attributes.Add("onclick", "return confirm('Är du säker på att du vill radera denna post?');")
End Select
End Sub
#End Region
#Region "Private Sub myGrid_EditCommand"
Private Sub myGrid_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles myGrid.EditCommand
Me.trMessage.Visible = False
Me.myGrid.EditItemIndex = e.Item.ItemIndex
Me.GetData()
Me.lblmessage.Text = String.Empty
End Sub
#End Region
#Region "Private Sub myGrid_CancelCommand"
Private Sub myGrid_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles myGrid.CancelCommand
Me.trMessage.Visible = False
Me.myGrid.EditItemIndex = -1
Me.GetData()
Me.lblmessage.Text = String.Empty
End Sub
#End Region
#Region "Private Sub myGrid_PageIndexChanged"
Private Sub myGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles myGrid.PageIndexChanged
Me.trMessage.Visible = False
Me.myGrid.CurrentPageIndex = e.NewPageIndex
Me.GetData()
End Sub
#End Region
#Region "Private Sub myGrid_DeleteCommand"
Private Sub myGrid_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles myGrid.DeleteCommand
Dim intID As Int32 = myGrid.DataKeys(e.Item.ItemIndex)
Dim intSucc As Int32
Dim con As New SqlConnection(strConn)
Dim cmd As New SqlCommand("DeleteNews", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@intNewsID", SqlDbType.Int).Value = intID
con.Open()
intSucc = cmd.ExecuteNonQuery
con.Close()
Me.trMessage.Visible = True
If intSucc > 0 Then
lblmessage.Text = "** Posten raderat **"
Else
lblmessage.ForeColor = Color.Red
lblmessage.Text = "** Posten raderades ej! **"
End If
myGrid.EditItemIndex = -1
GetData()
End Sub
#End Region
#Region "Private Sub myGrid_UpdateCommand"
Private Sub myGrid_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles myGrid.UpdateCommand
Dim intID As Int32 = myGrid.DataKeys(e.Item.ItemIndex)
Dim intSucc As Int32
Dim strRubrik As String = MakeSQLSafeString(CType(e.Item.FindControl("txtHeadline"), TextBox).Text.Trim)
Dim strNyhet As String = MakeSQLSafeString(CType(e.Item.FindControl("txtBody"), TextBox).Text.Trim)
Dim con As New SqlConnection(strConn)
Dim cmd As New SqlCommand("UpdateNews", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@Newsid", SqlDbType.Int).Value = intID
cmd.Parameters.Add("@strRubrik", SqlDbType.NVarChar, 100).Value = strRubrik
cmd.Parameters.Add("@strNews", SqlDbType.NText).Value = strNyhet
cmd.Parameters.Add("@Changed", SqlDbType.SmallDateTime).Value = DateTime.Now
cmd.Parameters.Add("@ChangedBy", SqlDbType.NVarChar, 50).Value = GlobalComponents.GetSessionCreds(UserID.GetID)
con.Open()
intSucc = cmd.ExecuteNonQuery
con.Close()
Me.trMessage.Visible = True
If intSucc > 0 Then
lblmessage.Text = "** Posten uppdaterad **"
Else
lblmessage.ForeColor = Color.Red
lblmessage.Text = "** Posten uppdaterad ej! **"
End If
myGrid.EditItemIndex = -1
GetData()
End Sub
#End Region
#Region "Private Sub lbtnShow_Click"
Private Sub lbtnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnShow.Click
Me.trNew.Visible = True
Me.lbtnShow.Visible = False
Me.lbtnHide.Visible = True
End Sub
#End Region
#Region "Private Sub lbtnHide_Click"
Private Sub lbtnHide_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnHide.Click
Me.trNew.Visible = False
Me.lbtnShow.Visible = True
Me.lbtnHide.Visible = False
End Sub
#End Region
#Region "Private Sub btnSend_Click"
Private Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Page.Validate()
If Page.IsValid Then
Dim strRubrik As String = MakeSQLSafeString(txtRubrik.Text.Trim)
Dim strNews As String = MakeSQLSafeString(txtNews.Text.Trim)
Dim intSucc As Int32
Dim con As New SqlConnection(strConn)
Dim cmd As New SqlCommand("InsertNews", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@strRubrik", SqlDbType.NVarChar, 100).Value = strRubrik
cmd.Parameters.Add("@strNews", SqlDbType.NText).Value = strNews
con.Open()
intSucc = cmd.ExecuteNonQuery
con.Close()
Me.trMessage.Visible = True
If intSucc > 0 Then
txtRubrik.Text = String.Empty
txtNews.Text = String.Empty
lblmessage.Text = "** Posten införd i databasen **"
Else
lblmessage.ForeColor = Color.Red
lblmessage.Text = "** Posten infördes ej! **"
End If
myGrid.EditItemIndex = -1
GetData()
End If
End Sub
#End Region
End Class
</code>Sv: Hur hitta kontroll i datagrid?
Tackar så mycket.