I have a gridview databound to an objectdatasource. Everything worked great until I changed 2 columns from asp:BoundField to asp:TemplateField. These are the UPC column and the Part column. I wanted to show a link button for each of these fields that take the user to another page. Now asp.net expects these two fields to be parameters on the update store procedure. Why is this? How do I get it to not assume these columns need to be passed to the store procedure?
Here is the code for the grid view:
<asp:GridView ID="GridView1" runat="server" SkinID="MSDefault" AutoGenerateColumns="False" DataSourceID="CartDataSource" PageSize="25"
Width="100%" DataKeyNames="CartId" EmptyDataText="The cart is empty" OnRowDataBound="GridView1_RowDataBound" onrowcommand="GridView1_RowCommand">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True">
<ItemStyle Width="8%" />
</asp:CommandField>
<asp:BoundField DataField="CartId" HeaderText="CartId" InsertVisible="False" ReadOnly="True"
SortExpression="CartId" Visible="False" />
<asp:TemplateField HeaderText="UPC" SortExpression="UPC">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="ShowInfo" CommandArgument='<%# Bind("UPC") %>' Text='<%# Bind("UPC") %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="9%" />
</asp:TemplateField>
<asp:BoundField DataField="Mfr" HeaderText="Mfr" ReadOnly="True" SortExpression="Mfr">
<ItemStyle Width="11%" />
</asp:BoundField>
<asp:TemplateField HeaderText="Part" SortExpression="Part">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="ShowInfo" CommandArgument='<%# Bind("UPC") %>' Text='<%# Bind("Part") %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:BoundField DataField="CustPart" HeaderText="Cust Part" ReadOnly="True" SortExpression="CustPart">
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="PartDesc" HeaderText="Description" ReadOnly="True" SortExpression="PartDesc">
<ItemStyle Width="30%" Wrap="True" />
</asp:BoundField>
<asp:TemplateField HeaderText="Marked" SortExpression="Marked">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Marked") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Marked") %>' Enabled="false" />
</ItemTemplate>
<ItemStyle Width="2%" />
</asp:TemplateField>
<asp:BoundField DataField="Quantity" DataFormatString="{0:d}" HeaderText="Quantity"
SortExpression="Quantity">
<ItemStyle HorizontalAlign="Right" Width="4%" />
</asp:BoundField>
<asp:TemplateField HeaderText="Price" SortExpression="Price">
<ItemStyle HorizontalAlign="Right" Width="8%" />
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server"></asp:Label>
<asp:LinkButton ID="LnkBtnCallLocalBranch" runat="server" Visible="false" PostBackUrl="~/UserProfile/LocalDistributors.aspx">call local branch</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Ext Price" SortExpression="ExtPrice">
<ItemStyle HorizontalAlign="Right" Width="8%" />
<ItemTemplate>
<asp:Label ID="lblExtPrice" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Here is the objectDataSource code
<asp:ObjectDataSource ID="CartDataSource" runat="server" OldValuesParameterFormatString="{0}" DeleteMethod="DeleteWithKey" SelectMethod="GetDataByCUserId"
TypeName="PunchoutData.CartDataSetTableAdapters.CartTableAdapter" UpdateMethod="UpdateQuantityAndMarked" OnUpdated="CartDataSource_Updated" OnObjectCreated="CartDataSource_ObjectCreated">
<DeleteParameters>
<asp:Parameter Name="cartid" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="marked" Type="Boolean" />
<asp:Parameter Name="quantity" Type="Int32" />
<asp:Parameter Name="cartid" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:SessionParameter Name="cuserid" SessionField="CUserId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
Here is the error that is being generated
ObjectDataSource 'CartDataSource' could not find a non-generic method 'UpdateQuantityAndMarked' that has parameters: Marked, Quantity, CartId, UPC, Part.
The issue was that I was using <%# Bind("UPC") %> and I should have been using <%# Eval("UPC") %>. Bind is two-way and Eval is one-way(read-only)
Related
I would like the header frozen at the top because i have over 9000 rows. I have tried "fixed" but that doesn't look the best. It was fixed in place on scroll but looked like it was floating in place. What can i do to get the top frozen? I tried a css style but it wasn't freezing the header either. If i can get the header frozen the next step is to freeze the footer on screen also so new entries can be made without having to go to the bottom on 9000 rows.
<asp:GridView id="myGridView" runat="server" AutoGenerateColumns="False"
CssClass="Grid"
Overflow="auto"
AllowSorting="False"
CellPadding="4"
ForeColor="#333333"
GridLines="None"
ShowFooter="True"
DataKeyNames="RMANumber" width="99%">
<AlternatingRowStyle BackColor="LightGray" />
<Columns>
<asp:TemplateField HeaderText="RMA Number" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblRMANumber" runat="server" ReadOnly="false" Text='<%# DataBinder.Eval(Container, "DataItem.RMANumber") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditRMANumber" size="16" runat="server" ReadOnly="false" Text='<%# DataBinder.Eval(Container, "DataItem.RMANumber") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddRMANumber" size="16" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Decon Form? Y/N" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblDeconForm" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.DeconForm") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditDeconForm" size="16" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.DeconForm") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddDeconForm" size="16" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblCustomer" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Customer") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditCustomer" size="16" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Customer") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddCustomer" size="16" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Problem / Solution Found" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label id="lblProblemSolutionFound" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ProblemSolutionFound") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtEditProblemSolutionFound" size="16" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ProblemSolutionFound") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtAddProblemSolutionFound" size="16" runat="server"></asp:TextBox>
<asp:Button id="btnAdd" runat="server" Text="Add" CommandName="Add" AutoPostBack="False" ></asp:Button>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" CancelText="Cancel" DeleteText="Delete" EditText="Edit" UpdateText="Update" HeaderText="Modify"
ShowDeleteButton="False" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left"
ButtonType="Image" CancelImageUrl="Images/Cancel.png" EditImageUrl="Images/Edit.png" UpdateImageUrl="Images/Update.png" ControlStyle-Width="60" ControlStyle-Height="20"/>
<asp:TemplateField HeaderText="Delete" ShowHeader="true" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left" >
<ItemTemplate>
<asp:ImageButton ID="DeleteButton" runat="server" ImageUrl="Images/Delete.png" Width="60" Height="20" VerticalAlign="Center"
CommandName="Delete"
AlternateText="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#ADD8E6" />
<FooterStyle BackColor="#ADD8E6" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
To keep the header at the top i used a script to duplicate the header and put it in it's own container. But I still had issues with the footer being visible. I decided to make a create button in a new page instead of dealing with the footer. It is much more cleaner for the user inputting data into a form instead of gridview footer. In the same fashion i use the edit record button to open the record in a new page for updating / editing it. I also made the gridview page sort by desc to only see the most recent RMAs, removed the duplicate header script, and used paging. no reason to see all the records, just the most recent.
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True"
PageSize="10"
AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="RMANumber"
CellPadding="1"
ForeColor="#333333"
DataSourceID="SqlDataSource1">
<AlternatingRowStyle BackColor="LightGray" />
<Columns>
<asp:CommandField ShowDeleteButton="False" ShowEditButton="True" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left"
ButtonType="Image" CancelImageUrl="Images/Cancel.png"
EditImageUrl="Images/Edit.png" UpdateImageUrl="Images/Update.png"
ControlStyle-Width="60" ControlStyle-Height="20">
<ControlStyle Height="20px" Width="60px"></ControlStyle>
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle"></HeaderStyle>
</asp:CommandField>
<asp:Boundfield DataField="RMANumber" HeaderText="RMA Number" ReadOnly="True" SortExpression="RMANumber" > <ItemStyle Width="5%" /> </asp:Boundfield>
<asp:BoundField DataField="DconForm" HeaderText="Dcon Form" SortExpression="DconForm" > <ItemStyle Width="3%" /> </asp:BoundField>
<asp:BoundField DataField="Customer" HeaderText="Customer" SortExpression="Customer" > <ItemStyle Width="10%" /> </asp:BoundField>
<asp:BoundField DataField="ItemBeingReturned" HeaderText="Item(s) Being Returned" SortExpression="ItemBeingReturned" > <ItemStyle Width="10%" /> </asp:BoundField>
<asp:BoundField DataField="ReasonForReturn" HeaderText="Reason For Return" SortExpression="ReasonForReturn" > <ItemStyle Width="15%" /> </asp:BoundField>
<asp:BoundField DataField="Dia" HeaderText="Dia" SortExpression="Dia" > <ItemStyle Width="7%" /> </asp:BoundField>
<asp:BoundField DataField="RMADate" HeaderText="RMA Date" SortExpression="RMADate" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="ReturnedDate" HeaderText="Returned Date" SortExpression="ReturnedDate" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="DateShipped" HeaderText="Date Shipped" SortExpression="DateShipped" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="PIKEContact" HeaderText="PIKE Contact" SortExpression="PIKEContact" > <ItemStyle Width="7%" /> </asp:BoundField>
<asp:BoundField DataField="DiamondResults" HeaderText="Diamond Results" SortExpression="DiamondResults" > <ItemStyle Width="5%" /> </asp:BoundField>
<asp:BoundField DataField="ProblemSolutionFound" HeaderText="Problem / Solution Found" SortExpression="ProblemSolutionFound" > <ItemStyle Width="15%" /> </asp:BoundField>
<asp:TemplateField HeaderText="" ShowHeader="true" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left" >
<ItemTemplate>
<asp:ImageButton ID="DeleteButton" runat="server" ImageUrl="Images/Delete.png" Width="60" Height="20" VerticalAlign="Center"
CommandName="Delete"
AlternateText="Delete" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle"></HeaderStyle>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#ADD8E6" />
<FooterStyle BackColor="#ADD8E6" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<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"
ConnectionString="<%$ ConnectionStrings:PIKE_Intranet_DBConnectionString %>"
DeleteCommand="DELETE FROM [RMATable] WHERE [RMANumber] = #RMANumber"
InsertCommand="INSERT INTO [RMATable] ([RMANumber], [DconForm], [Customer], [ItemBeingReturned], [ReasonForReturn], [Dia], [RMADate], [ReturnedDate], [DateShipped], [Status], [PIKEContact], [DiamondResults], [ProblemSolutionFound]) VALUES (#RMANumber, #DconForm, #Customer, #ItemBeingReturned, #ReasonForReturn, #Dia, #RMADate, #ReturnedDate, #DateShipped, #Status, #PIKEContact, #DiamondResults, #ProblemSolutionFound)"
SelectCommand="SELECT * FROM [RMATable] ORDER BY [RMANumber] DESC"
UpdateCommand="UPDATE [RMATable] SET [DconForm] = #DconForm, [Customer] = #Customer, [ItemBeingReturned] = #ItemBeingReturned, [ReasonForReturn] = #ReasonForReturn, [Dia] = #Dia, [RMADate] = #RMADate, [ReturnedDate] = #ReturnedDate, [DateShipped] = #DateShipped, [Status] = #Status, [PIKEContact] = #PIKEContact, [DiamondResults] = #DiamondResults, [ProblemSolutionFound] = #ProblemSolutionFound WHERE [RMANumber] = #RMANumber">
<DeleteParameters>
<asp:Parameter Name="RMANumber" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="RMANumber" Type="String" />
<asp:Parameter Name="DconForm" Type="String" />
<asp:Parameter Name="Customer" Type="String" />
<asp:Parameter Name="ItemBeingReturned" Type="String" />
<asp:Parameter Name="ReasonForReturn" Type="String" />
<asp:Parameter Name="Dia" Type="String" />
<asp:Parameter Name="RMADate" Type="String" />
<asp:Parameter Name="ReturnedDate" Type="String" />
<asp:Parameter Name="DateShipped" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="PIKEContact" Type="String" />
<asp:Parameter Name="DiamondResults" Type="String" />
<asp:Parameter Name="ProblemSolutionFound" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="DconForm" Type="String" />
<asp:Parameter Name="Customer" Type="String" />
<asp:Parameter Name="ItemBeingReturned" Type="String" />
<asp:Parameter Name="ReasonForReturn" Type="String" />
<asp:Parameter Name="Dia" Type="String" />
<asp:Parameter Name="RMADate" Type="String" />
<asp:Parameter Name="ReturnedDate" Type="String" />
<asp:Parameter Name="DateShipped" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="PIKEContact" Type="String" />
<asp:Parameter Name="DiamondResults" Type="String" />
<asp:Parameter Name="ProblemSolutionFound" Type="String" />
<asp:Parameter Name="RMANumber" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
</div>
</form>
I'm working with vb.net and have followed a tutorial to set up a gridview to update/delete/insert records into a table. I have a footer row that isn't working for me. when I click my insert button the textboxes from the footer do not do the insert. I think I am missing something fundamental that is causing this. May the page is posting back before the sub grabs the text from the textboxes? My understanding of it is pretty but I feel this could be the issue because I have two radio buttons that I use to switch between SQL data adapters because I want to be able to work with different tables. I have these set to postback="true". Could that be my issue?
SqlDataAdapter:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Server=SQLSERVER;Database=DB1;UID=user;PWD=password"
DeleteCommand="delete from AVZV_LoginRequestSales where id = #id"
SelectCommand="select * from AVZV_LoginRequestSales"
UpdateCommand="update AVZV_LoginRequestSales set name=#name, role = #role, supervisor = #supervisor, location = #location, trainingSdt = #trainingSdt, productionSdt = #productionSdt, terminatedDate = #terminatedDate, notes = #notes where id = #id">
<DeleteParameters>
<asp:Parameter Name="id" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="firstname" />
<asp:Parameter Name="lastname" />
<asp:Parameter Name="role" />
<asp:Parameter Name="supervisor" />
<asp:Parameter Name="location" />
<asp:Parameter Name="trainingSdt" />
<asp:Parameter Name="productionSdt" />
<asp:Parameter Name="terminatedDate" />
<asp:Parameter Name="notes" />
</UpdateParameters>
</asp:SqlDataSource>
Datagrid:
<asp:GridView ID="gvMatrix" runat="server"
AutoGenerateColumns="false" enableviewstate="false" showheaderwhenempty="true"
AllowSorting="True" emptydatatext="No Agents Listed" showfooter="true"
OnDataBound="OnDataBound" DataKeyNames="id" >
<Columns>
<asp:TemplateField HeaderText="Full Name" InsertVisible="False" SortExpression="FirstName">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newName" runat="server" placeholder="Full Name"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Role" InsertVisible="False" SortExpression="role">
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("role") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtrole" runat="server" Text='<%# Bind("role") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newrole" runat="server" placeholder="Role"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Supervisor" InsertVisible="False" SortExpression="supervisor">
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("supervisor") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtsupervisor" runat="server" Text='<%# Bind("supervisor") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newsupervisor" runat="server" placeholder="Supervisor"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Location" InsertVisible="False" SortExpression="location">
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("location") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtlocation" runat="server" Text='<%# Bind("location") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newlocation" runat="server" placeholder="Location"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Training Start Date" InsertVisible="False" SortExpression="trainingsdt">
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("trainingsdt") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txttrainingsdt" runat="server" Text='<%# Bind("trainingsdt") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newtrainingsdt" runat="server" placeholder="Training Start Date"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False"/>
</asp:TemplateField>
<asp:TemplateField HeaderText="Production Start Date" InsertVisible="False" SortExpression="Productionsdt">
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Productionsdt") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtProductionsdt" runat="server" Text='<%# Bind("Productionsdt") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newProductionsdt" runat="server" placeholder="Production Start Date"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False"/>
</asp:TemplateField>
<asp:TemplateField HeaderText="Terminated Date" InsertVisible="False" SortExpression="Terminateddate">
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Terminateddate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtTerminateddate" runat="server" Text='<%# Bind("Terminateddate") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newTerminateddate" runat="server" placeholder="Terminated Date"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False"/>
</asp:TemplateField>
<asp:TemplateField HeaderText="Notes" InsertVisible="False" SortExpression="notes">
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("notes") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtNotes" runat="server" Text='<%# Bind("notes") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:TextBox ID="newNotes" runat="server" placeholder="Notes"></asp:TextBox>
</FooterTemplate>
<FooterStyle Wrap="False"/>
</asp:TemplateField>
<asp:TemplateField>
<FooterTemplate>
<ItemTemplate>
<asp:Button ID="InsertRecord" runat="server" Text="Add Record" CommandName="Insert" />
</ItemTemplate>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" showeditbutton="true"/>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="deleteButton" runat="server" Text="Delete" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this record?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#3367a2" ForeColor="White" HorizontalAlign="Center" />
<RowStyle HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#2461bf" Font-Bold="True" ForeColor="blue" HorizontalAlign="Center" />
<EditRowStyle CssClass="gridview_edit" />
<FooterStyle CssClass="GVFixedFooter" />
<AlternatingRowStyle BackColor="#eff3fb" ForeColor="#3367a2" HorizontalAlign="Center" />
</asp:GridView>
Code for Insert:
Protected Sub gvMatrix_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gvMatrix.RowCommand
' Insert data if the CommandName == "Insert"
If e.CommandName = "Insert" AndAlso Page.IsValid Then
If rbSales.checked = True Then
SqlDataSource1.Insert()
Else
SqlDataSource2.Insert()
End If
End If
End Sub
Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting
' Programmatically reference Web controls in the inserting interface...
Dim NewName As TextBox = _
gvMatrix.FooterRow.FindControl("NewName")
Dim NewRole As TextBox = _
gvMatrix.FooterRow.FindControl("NewRole")
Dim NewSupervisor As TextBox = _
gvMatrix.FooterRow.FindControl("NewSupervisor")
Dim NewLocation As TextBox = _
gvMatrix.FooterRow.FindControl("NewLocation")
Dim Newtrainingsdt As TextBox = _
gvMatrix.FooterRow.FindControl("Newtrainingsdt")
Dim Newproductionsdt As TextBox = _
gvMatrix.FooterRow.FindControl("Newproductionsdt")
Dim Newterminateddate As TextBox = _
gvMatrix.FooterRow.FindControl("Newterminateddate")
Dim NewNotes As TextBox = _
gvMatrix.FooterRow.FindControl("NewNotes")
' Set the ObjectDataSource's InsertParameters values...
e.command.parameters("Name").Value = NewName.Text
e.command.parameters("role").Value = NewRole.Text
e.command.parameters("supervisor").Value = NewSupervisor.Text
e.command.parameters("location").Value = NewLocation.Text
e.command.parameters("trainingsdt").Value = Newtrainingsdt.Text
e.command.parameters("productionsdt").Value = Newproductionsdt.Text
e.command.parameters("terminatedDate").Value = Newterminateddate.Text
e.command.parameters("notes").Value = NewNotes.Text
End Sub
I know its a lot to look at but again I feel my issue might not be with the code so much as me missing a concept. Thanks in advance for any ideas/suggestions.
I'm having a problem with a couple of dropdown boxes in my gridview losing their values upon postback.
Everything is within an update panel so I have tried to include into my code but this just throws an exception. See the below code, I have a child gridview within a larger one:
I am receiving the following exception when I go to load the gridview: A control with ID 'DropDownNote' could not be found for the trigger in UpdatePanel 'UpdateGV'.
I followed what was in this post: Control in UpdatePanel loses value
But now I'm getting the above exception, what am I missing here? Will solving this problem retain the values of the dropdowns after the postback?
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:GridView ID="GVAccounts" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333"
GridLines="Horizontal"
style="position: relative; margin-top: 10px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="branch" HeaderText="Branch"
SortExpression="branch" />
<asp:BoundField DataField="no" HeaderText="Account"
SortExpression="account" />
<asp:TemplateField HeaderText="Name" SortExpression="name">
<EditItemTemplate>
<asp:TextBox ID="TextName" runat="server" Text='<%# Eval("name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelName" runat="server" Text='<%# Eval("name") + " " + Eval("surname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="type" HeaderText="Type" SortExpression="type" />
<asp:BoundField DataField="sub" HeaderText="Sub" SortExpression="sub" />
<asp:BoundField DataField="TotalAmount" HeaderText="Hold"
SortExpression="TotalAmount" />
<asp:BoundField DataField="loc" HeaderText="LOC" DataFormatString="{0:C}" SortExpression="loc" />
<asp:BoundField DataField="locstatus" HeaderText="LOC status"
SortExpression="locstatus" />
<asp:BoundField DataField="HoldCalc" HeaderText="OD/EX Amt" SortExpression="HoldCalc" />
<asp:BoundField DataField="odtimes" HeaderText="#OD" SortExpression="odtimes" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="gridChild" style="display: inline; position: relative; left: 15px; overflow: auto">
<asp:UpdatePanel ID="UpdateGV" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false"
BorderStyle="Double" BorderColor="#5D7B9D" Width="80%">
<HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true"
oncheckedchanged="chkSelect_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="effective" HeaderText="Effective" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="desc_" HeaderText="Desc" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="code" HeaderText="TC" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="amount" HeaderText="Amount" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="tracer" HeaderText="Cheq #" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="empltype" HeaderText="Empl" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="balance" HeaderText="OD/EXT Amt" HeaderStyle-HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Note">
<ItemTemplate>
<asp:DropDownList ID="DropDownNote" runat="server"
onselectedindexchanged="DropDownNote_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem></asp:ListItem>
<asp:ListItem>MWC</asp:ListItem>
<asp:ListItem>CBM</asp:ListItem>
<asp:ListItem>Return</asp:ListItem>
<asp:ListItem>TSF</asp:ListItem>
<asp:ListItem>OK NO S/C</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Note1">
<ItemTemplate>
<asp:DropDownList ID="ddNote2" runat="server">
<asp:ListItem Selected="True">NSF</asp:ListItem>
<asp:ListItem>Funds Not Clear</asp:ListItem>
<asp:ListItem>Post Dated</asp:ListItem>
<asp:ListItem>Stale Dated</asp:ListItem>
<asp:ListItem>Stop Payment</asp:ListItem>
<asp:ListItem>Encoding Incorrect</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Branch">
<ItemTemplate>
<asp:DropDownList ID="ddBranch" runat="server" DataSourceID="BranchDataSource"
DataTextField="branch" DataValueField="branch">
</asp:DropDownList>
<asp:SqlDataSource ID="BranchDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ThirdPartyDataConnectionString %>"
SelectCommand="SELECT [branch] FROM [branch]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Account">
<ItemTemplate>
<asp:TextBox ID="TextNo" runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type">
<ItemTemplate>
<asp:DropDownList ID="ddType" runat="server" DataSourceID="typeSource"
DataTextField="Type" DataValueField="Type">
</asp:DropDownList>
<asp:SqlDataSource ID="typeSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ThirdPartyDataConnectionString %>"
SelectCommand="SELECT [Type] FROM [DMDType]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub">
<ItemTemplate><asp:TextBox ID="TextSub" Width="25px" runat="server"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownNote" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
I decided to go a different route with this, I added MaintainScrollPositionOnPostback="true" to the top line of the aspx, since the complaint from the client was that the page would go back to the top after every postback. I had originally used the UpdatePanel to remedy this but decided this would be a better option.
Now my only problem is getting the page to retain the values of the dropdown boxes after a postback which I will have to figure out how that can be done.
I have a field named status in my gridview i want it like that so that when user clickes update on gridview in the place of textfield there will be an dropdown with published and unpublished option.here is the code
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource3">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="info" HeaderText="info" SortExpression="info" />
<asp:BoundField DataField="productcode" HeaderText="productcode" SortExpression="productcode" />
<asp:BoundField DataField="status" HeaderText="status" SortExpression="status" />
<asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" DeleteCommand="DELETE FROM [product_tbl] WHERE [Id] = #Id" InsertCommand="INSERT INTO [product_tbl] ([Id], [subcat], [name], [info], [brandid], [gender]) VALUES (#Id, #subcat, #name, #info, #brandid, #gender)" SelectCommand="SELECT * FROM [product_tbl]" UpdateCommand="UPDATE [product_tbl] SET [subcat] = #subcat, [name] = #name, [info] = #info, [brandid] = #brandid, [productcode] = #productcode, [gender] = #gender WHERE [Id] = #Id">
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="subcat" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="info" Type="String" />
<asp:Parameter Name="brandid" Type="Int32" />
<asp:Parameter Name="gender" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="subcat" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="info" Type="String" />
<asp:Parameter Name="brandid" Type="Int32" />
<asp:Parameter Name="productcode" Type="Int32" />
<asp:Parameter Name="gender" Type="Int32" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
For dropdown list you need to place templatefield
<asp:TemplateField HeaderText="Status">
<EditItemTemplate>
<asp:DropDownList ID="ddlStautus" runat="server">
<asp:ListItem>published</asp:ListItem>
<asp:ListItem>unpublished</asp:ListItem>
</asp:DropDowList>
</asp:TempLateFeild>
and bind your gridview on code behind
for more reference use This link
OR
<asp:GridView ID="GridView1" runat="server" CellPadding="4" DataKeyNames="UserID"
ForeColor="#333333" GridLines="None"
AutoGenerateColumns="False" onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating1"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdatabound="GridView1_RowDataBound1"
onrowdeleting="GridView1_RowDeleting">
<Columns>
<asp:TemplateField HeaderText="id" Visible="False">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" Width="75px"
Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblName" runat="server"
Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Info">
<EditItemTemplate>
<asp:TextBox ID="txtInfo" runat="server" Width="75px"
Text='<%# Bind("Info") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblInfo" runat="server"
Text='<%# Bind("Info") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="productcode">
<EditItemTemplate>
<asp:TextBox ID="txtproductcode" runat="server" Width="75px"
Text='<%# Bind("DomainID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblproductcode" runat="server"
Text='<%# Bind("productcode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "status">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%# Bind("status") %>' Visible="false"/>
<asp:DropDownList ID="ddlRole" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True"/>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<span onclick="return confirm('Are you sure to Delete the record?')">
<asp:LinkButton ID="lnkB" runat="Server" Text="Delete" CommandName="Delete"></asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and on code behind use code which is given in the link
I have a gridview which is displaying products information (code below)
now I would like to limit description field so that only the first few is shown if there is a long description and also resize the image to fit in the image column (and making the image, description column a bit bigger than the others
Thanks
<asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductId" OnRowDeleting="gvProducts_RowDeleting" OnSelectedIndexChanged="gvProducts_SelectedIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="Productname" HeaderText="Name" />
<asp:BoundField DataField="ProductDescription" HeaderText="Description" />
<asp:BoundField DataField="ProductSupplier" HeaderText="Supplier" />
<asp:BoundField DataField="ProductCategory" HeaderText="Category" />
<asp:BoundField DataField="ProductSubCategory" HeaderText="SubCategory" />
<asp:BoundField DataField="ProductVAT" HeaderText="VAT" />
<asp:BoundField DataField="ProductStock" HeaderText="Stock" />
<asp:ImageField DataImageUrlField="ProductImage" HeaderText="Image"/>
<asp:CheckBoxField DataField="ProductActive" HeaderText="Active" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Columns>
<SelectedRowStyle CssClass="selectedrow" />
</asp:GridView>
Using css we can limit the description text to be displayed. Like this....
<asp:GridView ID="gvProducts" runat="server" CssClass="GridCSS" AutoGenerateColumns="False" DataKeyNames="ProductId" OnRowDeleting="gvProducts_RowDeleting" OnSelectedIndexChanged="gvProducts_SelectedIndexChanged">
<Columns>
-----------------------
-----------
---------
<asp:BoundField DataField="ProductDescription" HeaderText="Description" ItemStyle-CssClass="limittext" />
------------------
---------
-------------
</Columns>
</asp:GridView>
CSS style:
.GridCSS {
table-layout:fixed;
width:100%;
}
.GridCSS .limittext{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
You can use mask for fw 4.5 or some external pluging lika Jquery Mask.
or You can make them Template Item and put some code like <%# Eval("ProductDescription").SubString(0,50) %>
If you're working with MVC, you can alter your GridView's data in your controller before binding it to GW. If you're not using MVC, the only thing I can offer is: in your RowDataBound event, check if description exceeds your defined max. chars and then truncate it.
Not a proper answer I know, but it may give you a few ideas. Can't provide code right now as I'm at work, but I'll check later if there is no answer to your post.
For further reading:
http://www.dotnetspider.com/resources/43687-How-show-formatted-html-content-grid-view.aspx
http://forums.asp.net/t/1391922.aspx/1
Try this
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<%# Eval("ProductDescription").ToString().Length > 50 ? Eval("ProductDescription").ToString().Substring(0,50)+"..." : Eval("ProductDescription").ToString() %>
</ItemTemplate>
</asp:TemplateField>
If text is more than 50 characters, display first 50, otherwise, display the whole text.
Another option is return a shortDescription from the database or from the Product object
public string ShortDescription
{
get
{
return ProductDescription.Length > 50 ? ProductDescription.Substring(0,50) : ProductDescription;
}
}
<table style="table-layout: fixed">
<tr>
<td>
<telerik:RadGrid ID="radGVEmployee" runat="server" AllowSorting="True" GridLines="None"
AutoGenerateColumns="False" CellSpacing="0" OnNeedDataSource="radGVEmployee_NeedDataSource"
Visible="True" OnSortCommand="radGVEmployee_SortCommand" AllowPaging="true" OnPageIndexChanged="radGVEmployee_PageIndexChanged"
Width="900px" OnItemDataBound="radGVEmployee_ItemDataBound" OnItemCommand="radGVEmployee_ItemCommand"
PageSize="5">
<FilterMenu EnableTheming="True">
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
<GroupingSettings CaseSensitive="False" />
<MasterTableView DataKeyNames="UsrId" AllowFilteringByColumn="true" TableLayout="Fixed"
Visible="true" AllowMultiColumnSorting="false">
<NoRecordsTemplate>
<div style="width: 700px;" align="center">
There is No Data to display</div>
</NoRecordsTemplate>
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
</ExpandCollapseColumn>
<Columns>
<telerik:GridTemplateColumn SortExpression="UserName" DataField="UserName" HeaderText="UserName"
HeaderStyle-Width="60px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblItmUserName" runat="server" Text='<%# Eval("UserName") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="FullName" DataField="FullName" HeaderText="FullName"
HeaderStyle-Width="60px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblItmFullName" runat="server" Text='<%# Eval("FullName") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="MobileNo" DataField="MobileNo" HeaderText="MobileNo"
HeaderStyle-Width="40px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblItmMobileNo" runat="server" Text='<%# Eval("MobileNo") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="CompanyName" DataField="CompanyName"
HeaderText="CompanyName" HeaderStyle-Width="50px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblItmCompanyName" runat="server" Text='<%# Eval("CompanyName") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="BranchName" DataField="BranchName" HeaderText="BranchName"
HeaderStyle-Width="50px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblItmBranchName" runat="server" Text='<%# Eval("BranchName") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="Designation" DataField="Designation"
HeaderText="Designation" HeaderStyle-Width="50px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblItmDesignation" runat="server" Text='<%# Eval("Designation") %>'></asp:Label>
<asp:Label ID="lblItmLockStatus" runat="server" Text='<%# Eval("LockStatus") %>'
Visible="false"></asp:Label>
<asp:Label ID="lblItmUserStatus" runat="server" Text='<%# Eval("UserStatus") %>'
Visible="false"></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn SortExpression="UserImage" DataField="UserImage" HeaderText="UserImage"
HeaderStyle-Width="50px" FilterControlWidth="75%" HeaderStyle-HorizontalAlign="Center"
AllowFiltering="false">
<ItemTemplate>
<asp:Image ID="lblUserImage" runat="server" ImageUrl='<%#Eval("ImageName")!=DBNull.Value?
System.Configuration.ConfigurationManager.AppSettings["AzureImagePath"]+Eval("ImageName"):System.Configuration.ConfigurationManager.AppSettings["UserImagePath"]+"profile-empty-head.gif"%>'
Height="100px" Width="90px" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn AllowFiltering="false" DataField="Actions" HeaderText="Actions"
HeaderStyle-Width="50px" HeaderStyle-HorizontalAlign="Center">
<%--OnClientClick='radconfirm("Are you sure you want to Change this LockStatus?", ClientGridCallback,300,150); return false;' --%>
<ItemTemplate>
<asp:ImageButton runat="server" ID="imgLockStatus" ImageUrl="~/App_Themes/DefaultClient/images/unlock.png"
CommandName="ChangeLockStatus" CommandArgument='<%# Eval("UsrId") %>' ToolTip="UserLockStatus"
AlternateText="LockStatus" OnClientClick="return blockConfirm('Are you sure you want to Change Lock Status?', event, 340, 150,'','Change Lock Status')" />
<asp:ImageButton runat="server" ID="imgUserStatus" ImageUrl="~/App_Themes/DefaultClient/images/select.png"
CommandName="ChangeUserStatus" CommandArgument='<%# Eval("UsrId") %>' ToolTip="UserActivationStatus"
AlternateText="UserActivationStatus" OnClientClick="return blockConfirm('Are you sure you want to Change Activation Status?', event, 340, 150,'','Change Activation Status')" />
<asp:ImageButton runat="server" ID="imgResetPassword" ImageUrl="~/App_Themes/DefaultClient/images/logoff.png"
CommandName="ResetPassword" CommandArgument='<%# Eval("UsrId") %>' ToolTip="ResetPassword"
Width="22px" Height="22px" AlternateText="ResetPassword" OnClientClick="return blockConfirm('Are you sure you want to Reset Password?', event, 340, 150,'','Reset Password')" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Wrap="false"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>
<%-- <telerik:GridButtonColumn ConfirmText="Are you sure you want to Change LockStatus ?<br /><br /><br />"
ConfirmDialogType="RadWindow" HeaderStyle-Width="15px" ConfirmDialogHeight="150px"
HeaderText="LockStatus" HeaderStyle-HorizontalAlign="Center" CommandName="ChangeLockStatus"
ButtonType="ImageButton" ImageUrl="~/App_Themes/DefaultClient/images/unlock.png"
ItemStyle-HorizontalAlign="Center" ConfirmTitle="Delete Currency" UniqueName="ChangeLockStatus">
</telerik:GridButtonColumn>
<telerik:GridButtonColumn ConfirmText="Are you sure you want to Change ActivationStatus ?<br /><br /><br />"
ConfirmDialogType="RadWindow" HeaderStyle-Width="15px" ConfirmDialogHeight="150px"
HeaderText="ActivationStatus" HeaderStyle-HorizontalAlign="Center" CommandName="ChangeUserStatus"
ButtonType="ImageButton" ImageUrl="~/App_Themes/DefaultClient/images/unlock.png"
ItemStyle-HorizontalAlign="Center" ConfirmTitle="Delete Currency" UniqueName="ChangeUserStatus">
</telerik:GridButtonColumn>--%>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<GroupingSettings CaseSensitive="False" />
<ClientSettings>
<ClientEvents OnGridCreated="GridCreated" />
</ClientSettings>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
</td>
</tr>
</table>
Try this ..........