Monday, March 12, 2012

how to Copy Item one Gridview to another gridview

I have Two gridview left side where i populate data from Database and other will be empty at 1st time my requirement is when click any item and click to add button it will remove from that cell and add in to second gridview

same thing happens through drag and drop system Drag from one gridview to another well but it will be helpfull how to remove and add one gridview to another can someone give me idea

bye take care
regards
vikrant

Check out these links

http://forums.asp.net/p/1169459/1955946.aspx

http://www.codeproject.com/KB/HTML/SelectMoveRowsFromTables.aspx

Labels: , , , , , , , , , ,

How to copy gridview cell values?

I have a gridview that displays item #'s and my users want to be able to highlight any number and copy it by either right clicking or ctrl + c. But for some reason the individual cells can't be highlighted by double clicking. And when dragging over text it highlights the entire table!

<asp:GridView BorderWidth=1px BorderColor=Black Borderstyle=Solid HeaderStyle-BackColor=Aquamarine runat=server style="z-index: 100; left: 9px; position: absolute; top: 106px" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" ID="GridView1" AllowPaging="True" AllowSorting="True"> <Columns> <asp:BoundField DataField="itemNumber" HeaderText="#" SortExpression="itemNumber" > <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col" ForeColor="#0000C0" /> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> </asp:BoundField> <asp:BoundField DataField="FirstPayDate" HeaderText="First Pay Date" SortExpression="FirstPayDate" > <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col" ForeColor="#0000C0" /> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> </asp:BoundField> <asp:BoundField DataField="Screen" HeaderText="Screen" SortExpression="Screen" > <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col" ForeColor="#0000C0" /> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> </asp:BoundField> <asp:BoundField DataField="Problem" HeaderText="Problem" SortExpression="Problem" > <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col" ForeColor="#0000C0" /> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> </asp:BoundField> <asp:BoundField DataField="DateIn" HeaderText="Date in" SortExpression="DateIn" > <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col" ForeColor="#0000C0" /> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> </asp:BoundField> <asp:BoundField DataField="Code" HeaderText="Code" SortExpression="Code" > <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col" ForeColor="#0000C0" /> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" /> </asp:BoundField> <asp:CommandField HeaderText="Action" SelectText="Fixed" ShowSelectButton="True"> <ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CssClass="Col"/> <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" /> </asp:CommandField> </Columns> <PagerTemplate> Goto Page <asp:DropDownList ID="ddlPageSelector" OnSelectedIndexChanged="pageChange" runat="server" AutoPostBack="true"> </asp:DropDownList>  Total Errors: <asp:Label ID="lbl_Total" runat="server" Text="Label"></asp:Label> </PagerTemplate> <HeaderStyle BackColor="Aquamarine" /></asp:GridView>

Try using a TemplateField instead of the BoundField. Then use a span to display your info.

Labels: , , , , , , , , , , , ,

How to convert datareader.items value to integer

Hi,

I have a datareader item

myreader.Item("netcost")

This is a numeric value, I need to take the value and minus 500 from it, I have

(myreader.Item("netcost")-500)

This causes an error, 'cannot cast from string to integer'

How do I do it?

Thanks. BenYou can use Ctype.

For example, this converts you datareader item to an integer.

CType(myreader.Item("netcost"),Integer) - 500
Convert.ToInt32(myreader.Item("netcost").ToString())

Labels: , , , , , , , , , , ,