G
Guest
Hello,
<aspataGrid ID="dg1" AllowPaging="True" AllowSorting="True"
AlternatingItemStyle-BackColor="#ccccff"
AlternatingItemStyle-Font-Name="arial"
AlternatingItemStyle-ForeColor="#333366" CellPadding="3"
DataKeyField="empid" OnPageIndexChanged="chgpage"
OnSortCommand="sortdg" PageSize="10" PagerStyle-Mode="NumericPages"
Runat="server" PagerStyle-HorizontalAlign="Center"
OnSelectedIndexChanged="chgsel" SelectedItemStyle-BackColor="#FF0000"
AutoGenerateColumns="False" PagerStyle-BackColor="#4682b4"
PagerStyle-Font-Bold="True" PagerStyle-ForeColor="#FFFF00"
PagerStyle-Font-Name="arial,verdana" BorderColor="#4682b4"
BorderStyle="Solid" BorderWidth="2"
OnEditCommand="chkedit" OnCancelCommand="chkcancel"
OnUpdateCommand="chkupd" OnItemCommand="chkitem">
<HeaderStyle Font-Name="arial,verdana" ForeColor="#FFFF00"
BackColor="#4682b4"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="empid" HeaderText="Emp ID"
SortExpression="empid" ReadOnly="True"></asp:BoundColumn>
<asp:BoundColumn DataField="empname" HeaderText="Name"
SortExpression="empname"></asp:BoundColumn>
<asp:BoundColumn DataField="passportno" HeaderText="Passport
No"></asp:BoundColumn>
<asp:BoundColumn DataField="curbasic" HeaderText="Basic"
SortExpression="curbasic"></asp:BoundColumn>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
UpdateText="Update" HeaderText="Edit Item">
<ItemStyle HorizontalAlign="Center" Wrap="False"></ItemStyle>
</asp:EditCommandColumn>
<asp:ButtonColumn HeaderText="Delete Item" Text="Delete"
ButtonType="PushButton" CommandName="delete"></asp:ButtonColumn>
</Columns>
</aspataGrid>
in the onitemcommand procedure,
select case ctype(e.commandsource,button).commandname
case "delete"
delete()
end select
when i press delete button, its working fine. For any other operation(sort,
page changed, edit or cancel or update) displaying an error "cast invalid at
ctype(e.commandsource,button).commandname "
Coz edit and cancel are LinkButtons and Delete is Pushbutton.
How can i validate whether e.commandsource is button or linkbutton?
And when i click Edit, datagrid columns are incorporated with textboxes
those who have been allowed for editing. Here, the textbox is displaying its
default size. How can i specify diff widths for each textbox in each column?
thanks in advance
<aspataGrid ID="dg1" AllowPaging="True" AllowSorting="True"
AlternatingItemStyle-BackColor="#ccccff"
AlternatingItemStyle-Font-Name="arial"
AlternatingItemStyle-ForeColor="#333366" CellPadding="3"
DataKeyField="empid" OnPageIndexChanged="chgpage"
OnSortCommand="sortdg" PageSize="10" PagerStyle-Mode="NumericPages"
Runat="server" PagerStyle-HorizontalAlign="Center"
OnSelectedIndexChanged="chgsel" SelectedItemStyle-BackColor="#FF0000"
AutoGenerateColumns="False" PagerStyle-BackColor="#4682b4"
PagerStyle-Font-Bold="True" PagerStyle-ForeColor="#FFFF00"
PagerStyle-Font-Name="arial,verdana" BorderColor="#4682b4"
BorderStyle="Solid" BorderWidth="2"
OnEditCommand="chkedit" OnCancelCommand="chkcancel"
OnUpdateCommand="chkupd" OnItemCommand="chkitem">
<HeaderStyle Font-Name="arial,verdana" ForeColor="#FFFF00"
BackColor="#4682b4"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="empid" HeaderText="Emp ID"
SortExpression="empid" ReadOnly="True"></asp:BoundColumn>
<asp:BoundColumn DataField="empname" HeaderText="Name"
SortExpression="empname"></asp:BoundColumn>
<asp:BoundColumn DataField="passportno" HeaderText="Passport
No"></asp:BoundColumn>
<asp:BoundColumn DataField="curbasic" HeaderText="Basic"
SortExpression="curbasic"></asp:BoundColumn>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
UpdateText="Update" HeaderText="Edit Item">
<ItemStyle HorizontalAlign="Center" Wrap="False"></ItemStyle>
</asp:EditCommandColumn>
<asp:ButtonColumn HeaderText="Delete Item" Text="Delete"
ButtonType="PushButton" CommandName="delete"></asp:ButtonColumn>
</Columns>
</aspataGrid>
in the onitemcommand procedure,
select case ctype(e.commandsource,button).commandname
case "delete"
delete()
end select
when i press delete button, its working fine. For any other operation(sort,
page changed, edit or cancel or update) displaying an error "cast invalid at
ctype(e.commandsource,button).commandname "
Coz edit and cancel are LinkButtons and Delete is Pushbutton.
How can i validate whether e.commandsource is button or linkbutton?
And when i click Edit, datagrid columns are incorporated with textboxes
those who have been allowed for editing. Here, the textbox is displaying its
default size. How can i specify diff widths for each textbox in each column?
thanks in advance