This is a migrated thread and some comments may be shown as answers.

Grid Edit Form Settings

4 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rama
Top achievements
Rank 1
Rama asked on 05 Jan 2011, 12:53 PM

<EditFormSettings EditColumn-UpdateText="Update" EditColumn-ButtonType="ImageButton" PopUpSettings-Modal="true" InsertCaption="Add new item" CaptionFormatString="ITAdmin: {0} " CaptionDataField="EmployeeName" EditFormType="Template">
<FormTemplate>
<table id="tblUs" cellspacing="1" cellpadding="1" width="250" border="0">
<tr><td></td><td></td></tr><tr><td></td><td>
 <table width="245px" id="TBLUSERS" border="0" cellspacing="0" cellpadding="0">
<tr><td>
 <asp:TextBox ID="GridtxtSearch" runat="server" Width="175px"></asp:TextBox>
 <asp:Button ID="GrdbtnGo" runat="server" OnClick="Populate" Text="Go" />
 <asp:Label Visible="false" runat="server" ID="hdnId" Text='<%#Eval("id") %>' />
 <asp:Label Visible="false" runat="server" ID="hdnSiteName" Text='<%#Eval("Name") %>' />
 <asp:Label Visible="false" runat="server" ID="hdnITAdminName" Text='<%#Eval("EmployeeName") %>' />
 <asp:Label Visible="false" runat="server" ID="hdnITAdminId" Text='<%#Eval("ITAdminId") %>' />
 
</td> <td>
&nbsp;

</td>
</tr>
<tr>
<td>
Entity : <asp:DropDownList ID="drpSiteCode_" AppendDataBoundItems="true" runat="server" AutoPostBack="false">
<asp:ListItem Value="-">Select --</asp:ListItem>
</asp:DropDownList>
<span style="color: Red">
<asp:RequiredFieldValidator ID="rfvSite" runat="server" ControlToValidate="drpSiteCode_"
ErrorMessage="Please select an Entity" ValidationGroup="rfGrdSiteCode" InitialValue="-" Font-Size="Smaller"></asp:RequiredFieldValidator>
</span>
</td>
<td>
&nbsp;
</td>

</tr>
<tr>
 
<td>
 

<table>
 

<tr>
 

 

<td>

<asp:ListBox Width="233px" ID="GrdlstallNetIds" runat="server" SelectionMode="Single"
 
Height="270px"></asp:ListBox>
 

</td>

</tr>

</table>

</td>

</tr>
 
<tr>
 
<td>

 

<asp:Label ID="lbNoRecordsExistMyRequestsf" runat="server" Font-Size="Smaller"></asp:Label>
 

</td>
 

</tr>
 

</table>
 

</td>
 

 

</tr>
 

</table>
 

<table style="width: 100%">
 

<tr>
 

<td align="right" colspan="2">
 

<asp:Button ValidationGroup="rfGrdSiteCode" ID="Button2" Text='<%# Iif (TypeOf Container is GridEditFormInsertItem, "Insert", "Update") %>'
 

runat="server" CommandName='<%# Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'>
 

</asp:Button>&nbsp;
 

<asp:Button ID="Button3" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">

</asp:Button>
 

</td>
 

</tr>
 

</table>

</FormTemplate>
 

<FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle>
 

<FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle>
 

<FormStyle Width="100%" BackColor="#eef2ea"></FormStyle>
 

<EditColumn ButtonType="ImageButton" />
 

<PopUpSettings Modal="true" />
 

</EditFormSettings>

 

When btnGo is Clicked ,

I want to get the GridtxtSearch value to repopulate the GrdlstallNetIds everytime.But always when the First row in the Grid is selected , I can able to get the GridtxtSearch value , Can u help me to check how to get the selected griditem
GridtxtSearch  value?

Protected Sub Populate()
 

Dim grditem As GridItem
 
 

grditem = rdGridSite.MasterTableView.GetItems(

GridItemType.EditFormItem)(0)
 

Dim txtSearch As TextBox = CType(grditem.FindControl("GridtxtSearch"), TextBox)

Dim hdnId As Label = CType(grditem.FindControl("hdnId"), Label)
 

Dim GrdlstallNetIds As ListBox = CType(grditem.FindControl("GrdlstallNetIds"), ListBox)
 

 

Try
 

Dim empDao1 As New EmployeeDAL()
 

Dim ds1 As New DataSet()
 

If txtSearch.Text = String.Empty Then
 

 

ds1 = empDao1.GetAllNetworkids()

Else
 

 

ds1 = empDao1.GetAllNetworkids(txtSearch.Text)

 
End If
 

Dim dt As New DataTable()
 

dt = ds1.Tables(0)

GrdlstallNetIds.DataSource = dt

GrdlstallNetIds.DataTextField = "DisplayName"
 
 

GrdlstallNetIds.DataValueField = "SamaccountName"
 

 
 

GrdlstallNetIds.DataBind()
 Catch ex As Exception

Exit Sub

End Try

 End Sub 

 

 

Thanks

 

 

4 Answers, 1 is accepted

Sort by
0
Rama
Top achievements
Rank 1
answered on 07 Jan 2011, 08:05 AM
Can anyone help please on this issue, its very urgent pl
0
Princy
Top achievements
Rank 2
answered on 07 Jan 2011, 08:20 AM
Hello Rama,

Try the following approach to access the TextBox value.

VB.NET:
Protected Sub Populate(sender As Object, e As EventArgs)
    Dim btn As Button = DirectCast(sender, Button)
    Dim grditem As GridEditFormItem = DirectCast(btn.NamingContainer, GridEditFormItem)
    Dim txtSearch As TextBox = DirectCast(grditem.FindControl("GridtxtSearch"), TextBox)
         .     .     .    .     .  .    .   .
End Sub

Thanks,
Princy.
0
Rama
Top achievements
Rank 1
answered on 07 Jan 2011, 08:54 AM
Hi Princy
Thanks for ur reply. I tried ur code.

 

 

<asp:Button ID="GrdbtnGo" runat="server" OnClick="Populate()" Text="Go" />

 

The error is
Argument not specified for parameter 'e' of 'Protected Sub Populate(sender As Object, e As System.EventArgs)'.

 

 

Public Sub Populate(ByVal sender As Object, ByVal e As EventArgs)

 

 

 

Dim btn As Button = DirectCast(sender, Button)

 

 

 

Dim grditem As GridEditFormItem = DirectCast(btn.NamingContainer, GridEditFormItem)

 

 

 

Dim txtSearch As TextBox = DirectCast(grditem.FindControl("GridtxtSearch"), TextBox)

 

...end sub

Please ...

0
Rama
Top achievements
Rank 1
answered on 07 Jan 2011, 08:56 AM
huh..its the mistake with OnClick="Populate()"  should be Populate
Its working fine now..
Thanks you very much for your help and support


Tags
Grid
Asked by
Rama
Top achievements
Rank 1
Answers by
Rama
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or